3v4l.org

run code in 300+ PHP versions simultaneously
<?php $points = [ 'x' => [1, 3, 5], 'y' => [2, 4, 6], ]; // use labels 'x' and 'y' (hard coded) $size = count($points['x']); for($i=0; $i < $size; $i++) { $newPoints0[$i] = ['x' => $points['x'][$i], 'y' => $points['y'][$i]]; } print_r($newPoints0); // labels 'x' and 'y' could change (dynamic) $keys = array_keys($points); $x = $points[$keys[0]]; // fetch label $y = $points[$keys[1]]; // fetch label $size = count($x); for($i=0; $i < $size; $i++) { $newPoints1[$i] = [$keys[0] => $x[$i], $keys[1] => $y[$i]]; } print_r($newPoints1);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [x] => 1 [y] => 2 ) [1] => Array ( [x] => 3 [y] => 4 ) [2] => Array ( [x] => 5 [y] => 6 ) ) Array ( [0] => Array ( [x] => 1 [y] => 2 ) [1] => Array ( [x] => 3 [y] => 4 ) [2] => Array ( [x] => 5 [y] => 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:
58.73 ms | 1627 KiB | 4 Q