3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [2,5,1,12,-5,4,-1,3,-3,20,8,7,-2,6,9]; $a = $arr; asort($a); $a = array_chunk($a, 5); $output = []; $idx = 0; while($a){ if($idx++ % 2){ $b = array_pop($a); arsort($b); }else{ $b = array_shift($a); } $output = array_merge($output, $b); } var_dump($output);
Output for rfc.property-hooks, git.master, git.master_jit
array(15) { [0]=> int(-5) [1]=> int(-3) [2]=> int(-2) [3]=> int(-1) [4]=> int(1) [5]=> int(20) [6]=> int(12) [7]=> int(9) [8]=> int(8) [9]=> int(7) [10]=> int(2) [11]=> int(3) [12]=> int(4) [13]=> int(5) [14]=> int(6) }

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:
49.15 ms | 1450 KiB | 4 Q