3v4l.org

run code in 300+ PHP versions simultaneously
<?php function reKey($oldArray, $value, $newArray=Array()) { if (count($oldArray)) { $currentValue = current($oldArray); unset($oldArray[key($oldArray)]); $newArray[$currentValue] = Array(); print_r($newArray); $newArray = reKey($oldArray, $value, $newArray[$currentValue]); } else{ $newArray[key($newArray)] = $value; } return $newArray; } $array = Array( 0 => "this", 1 => "that", 2 => "those", 3 => "they", ); $newArray = reKey($array, "asdadsad", Array()); print_r($newArray);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [this] => Array ( ) ) Array ( [that] => Array ( ) ) Array ( [those] => Array ( ) ) Array ( [they] => Array ( ) ) Array ( [] => asdadsad )

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