3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'one' => 'string1', 'two' => 'string2', 'three' => 'string3', 'four' => 'string4'); $aNewArray=array(); foreach($array as $key=>$value) { switch($key) { case 'one': $aNewArray[3]['one']=$value; break; case 'two': $aNewArray[2]['two']=$value; break; case 'three': $aNewArray[1]['three']=$value; break; case 'four': $aNewArray[1]['four']=$value; break; } } print_r($aNewArray);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [3] => Array ( [one] => string1 ) [2] => Array ( [two] => string2 ) [1] => Array ( [three] => string3 [four] => string4 ) )

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