3v4l.org

run code in 300+ PHP versions simultaneously
<?php $master_array = array(1, 2, 3, 4, 5, 6); $n = 2; // This is the number of columns / arrays $pattern_array = array(); $meta_array = array(); for ($i=1, $z=2*$n; $i <= $n; ++$i) { $pattern_array[$i] = $i; $pattern_array[$z-$i] = $i; $meta_array[] = array(); } foreach ($master_array as $i => $element) { $pattern_index = $i % $z; $meta_index = $pattern_array[$pattern_index] - 1; $meta_array[$meta_index][] = $element; } print_r($meta_array);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key 0 in /in/88jhN on line 17 Warning: Undefined array key 0 in /in/88jhN on line 17 Array ( [0] => Array ( [0] => 2 [1] => 4 [2] => 6 ) [1] => Array ( [0] => 3 ) [-1] => Array ( [0] => 1 [1] => 5 ) )

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:
39.68 ms | 402 KiB | 8 Q