3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('red', 'white', 'blue'); $new_array = array(); $temp_array = &$new_array; foreach ($array as $item) { $temp_array = &$temp_array['and']; // $temp_array now equals null, // and it's references to parent array item with key and $temp_array['like'] = $item; } unset($temp_array); print_r($new_array);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [and] => Array ( [like] => red [and] => Array ( [like] => white [and] => Array ( [like] => blue ) ) ) )

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