3v4l.org

run code in 300+ PHP versions simultaneously
<?php function moveKeyBefore($arr, $find, $move) { if (!isset($arr[$find], $arr[$move])) { return $arr; } $elem = [$move=>$arr[$move]]; // cache the element to be moved $start = array_splice($arr, 0, array_search($find, array_keys($arr))); unset($start[$move]); // only important if $move is in $start return $start + $elem + $arr; } $arr = ['foo1'=>'bar', 'foo2'=>'buzz', 'foo3'=>'bazz']; var_export(moveKeyBefore($arr, 'foo3', 'foo1'));
Output for git.master, git.master_jit
/bin/php-git-master: error while loading shared libraries: libonig.so.5: cannot open shared object file: No such file or directory
Process exited with code 127.
Output for rfc.property-hooks
array ( 'foo2' => 'buzz', 'foo1' => 'bar', 'foo3' => 'bazz', )

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