3v4l.org

run code in 300+ PHP versions simultaneously
<?php $C = ['B' => ['S' => ['C' => []], 'H' => ['D' => []], 'G' => ['L' => []]]]; function moveArrayElementOnTop($array, $element = 'H') { $finalArray = array(); foreach ($array as $key => $values) { foreach ($values as $k => $v) { if ($k == $element) { $temp[$key][$k] = $v; unset($array[$key][$k]); } } if (isset($temp[$key])) { $finalArray[$key] = $temp[$key] + $array[$key]; } else { $finalArray[$key] = $array[$key]; } } return $finalArray; } echo "<pre>"; print_r(moveArrayElementOnTop($C)); echo "</pre>";
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [B] => Array ( [H] => Array ( [D] => Array ( ) ) [S] => Array ( [C] => Array ( ) ) [G] => Array ( [L] => Array ( ) ) ) ) </pre>

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:
41.8 ms | 402 KiB | 8 Q