3v4l.org

run code in 300+ PHP versions simultaneously
<?php $id = [11,12,13,56,34,23,34]; $code = ['1234','5678','9012','4343','4543','4642','534']; $qty = [3,4,5,6,7,8,3]; $amount = [12.34,23.45,34.56,66.34,75.32,54.3,23.2]; $loopRun = 0; $max = count($id); $data = []; for ($i=0; $i<ceil($max/2); $i++) { $loopRun++; $data[$i] = [ 'id' => $id[$i], 'code' => $code[$i], 'qty' => $qty[$i], 'amount' => $amount[$i] ]; $data[$max-($i+1)] = [ 'id' => $id[$max-($i+1)], 'code' => $code[$max-($i+1)], 'qty' => $qty[$max-($i+1)], 'amount' => $amount[$max-($i+1)] ]; } ksort($data); echo "Loop Run Count : ".$loopRun."\n\n"; print_r($data);
Output for git.master, git.master_jit, rfc.property-hooks
Loop Run Count : 4 Array ( [0] => Array ( [id] => 11 [code] => 1234 [qty] => 3 [amount] => 12.34 ) [1] => Array ( [id] => 12 [code] => 5678 [qty] => 4 [amount] => 23.45 ) [2] => Array ( [id] => 13 [code] => 9012 [qty] => 5 [amount] => 34.56 ) [3] => Array ( [id] => 56 [code] => 4343 [qty] => 6 [amount] => 66.34 ) [4] => Array ( [id] => 34 [code] => 4543 [qty] => 7 [amount] => 75.32 ) [5] => Array ( [id] => 23 [code] => 4642 [qty] => 8 [amount] => 54.3 ) [6] => Array ( [id] => 34 [code] => 534 [qty] => 3 [amount] => 23.2 ) )

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:
159.64 ms | 409 KiB | 5 Q