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
Fatal error: Uncaught Error: Undefined constant "n" in /in/cfWTn:8 Stack trace: #0 {main} thrown in /in/cfWTn on line 8
Process exited with code 255.

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:
45.85 ms | 401 KiB | 8 Q