fork(5) download
  1. <?php
  2. function adjustArray($myArray, $lineLimit = 3){
  3. $count = count($myArray);
  4.  
  5. if ($count % $lineLimit != 0){
  6. $myArray = array_merge($myArray, array_fill(0, $lineLimit - $count % $lineLimit, ""));
  7. }
  8.  
  9. return $myArray;
  10. }
  11. var_dump(adjustArray(array("foo")));
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
array(3) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(0) ""
  [2]=>
  string(0) ""
}