3v4l.org

run code in 300+ PHP versions simultaneously
<?php function swapOffsets(array $array, $offset1, $offset2) { $keys = array_keys($array); $key1 = $keys[$offset1]; $key2 = $keys[$offset2]; $value1 = $array[$key1]; $value2 = $array[$key2]; array_splice($array, $offset1, 1, array($key2 => $value2)); array_splice($array, $offset2, 1, array($key1 => $value1)); return $array; } var_dump(swapOffsets(['a' => 1, 'b' => 2, 'c' => 3], 0, 2));
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> int(3) ["b"]=> int(2) [1]=> int(1) }

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.3 ms | 401 KiB | 8 Q