3v4l.org

run code in 300+ PHP versions simultaneously
<?php function restructure($x,$slots) { $result=array(); $count=count($x); $least=(int)($count/$slots); $excess=$count-$least*$slots; for($i=0;$i<($least+1)*$excess;$i+=$least+1) array_push($result,implode(", ",array_slice($x,$i,$least+1))); for(;$i<$count;$i+=$least) array_push($result,implode(", ",array_slice($x,$i,$least))); return $result; } $x=array( "item 1", "item 2", "item 3", "item 4", "item 5", "item 6", "item 7", ); print_r(restructure($x,5));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => item 1, item 2 [1] => item 3, item 4 [2] => item 5 [3] => item 6 [4] => item 7 )

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:
26.15 ms | 405 KiB | 5 Q