3v4l.org

run code in 300+ PHP versions simultaneously
<?php function custom_chunk($array, $maxrows) { $size = sizeof($array); $columns = ceil($size / $maxrows); $fullrows = $size - ($columns - 1) * $maxrows; for ($i = 0; $i < $maxrows; ++$i) { $result[] = array_splice($array, 0, ($i < $fullrows ? $columns : $columns - 1)); } return $result; } var_export(custom_chunk(range('a', 'r'), 12));
Output for git.master_jit, git.master, rfc.property-hooks
array ( 0 => array ( 0 => 'a', 1 => 'b', ), 1 => array ( 0 => 'c', 1 => 'd', ), 2 => array ( 0 => 'e', 1 => 'f', ), 3 => array ( 0 => 'g', 1 => 'h', ), 4 => array ( 0 => 'i', 1 => 'j', ), 5 => array ( 0 => 'k', 1 => 'l', ), 6 => array ( 0 => 'm', ), 7 => array ( 0 => 'n', ), 8 => array ( 0 => 'o', ), 9 => array ( 0 => 'p', ), 10 => array ( 0 => 'q', ), 11 => array ( 0 => 'r', ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
50.84 ms | 402 KiB | 8 Q