3v4l.org

run code in 300+ PHP versions simultaneously
<?php function merge(array $a, array $b) { foreach ($b as $key => $value) { if (isset($key, $a)) { if (is_int($key)) { $a[] = $value; } elseif (is_array($value) && is_array($a[$key])) { $a[$key] = merge($a[$key], $value); } else { $a[$key] = $value; } } else { $a[$key] = $value; } } return $a; } $a = array('person' => array( 'name' => 'franz', 'last_name' => 'de leon', )); $b = array('person' => array( 'name' => 'cheryl', )); var_dump(merge($a, $b));
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { ["person"]=> array(2) { ["name"]=> string(6) "cheryl" ["last_name"]=> string(7) "de leon" } }

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