3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $_rows = array(); for($i = 1; $i <= 28; $i++) { if(in_array($i, array(1,2))) { $_rows['row1'][] = 'Category '.$i; } if(in_array($i, array(3,4,5))) { $_rows['row2'][] = 'Category '.$i; } if(in_array($i, array(6,7,8))) { $_rows['row3'][] = 'Category '.$i; } if(in_array($i, array(9,10,11))) { $_rows['row4'][] = 'Category '.$i; } if(in_array($i, array(12,13))) { $_rows['row5'][] = 'Category '.$i; } if(in_array($i, array(14,15,16))) { $_rows['row6'][] = 'Category '.$i; } if(in_array($i, array(17,18,19))) { $_rows['row7'][] = 'Category '.$i; } if(in_array($i, array(20,21,22))) { $_rows['row8'][] = 'Category '.$i; } if(in_array($i, array(23,24,25))) { $_rows['row9'][] = 'Category '.$i; } if(in_array($i, array(26,27,28))) { $_rows['row10'][] = 'Category '.$i; } } foreach($_rows as $_row) { print_r($_row); }
Output for 4.3.0 - 7.1.0
Array ( [0] => Category 1 [1] => Category 2 ) Array ( [0] => Category 3 [1] => Category 4 [2] => Category 5 ) Array ( [0] => Category 6 [1] => Category 7 [2] => Category 8 ) Array ( [0] => Category 9 [1] => Category 10 [2] => Category 11 ) Array ( [0] => Category 12 [1] => Category 13 ) Array ( [0] => Category 14 [1] => Category 15 [2] => Category 16 ) Array ( [0] => Category 17 [1] => Category 18 [2] => Category 19 ) Array ( [0] => Category 20 [1] => Category 21 [2] => Category 22 ) Array ( [0] => Category 23 [1] => Category 24 [2] => Category 25 ) Array ( [0] => Category 26 [1] => Category 27 [2] => Category 28 )