3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array('foo' => "xyz", null => "abc"); $b = array('bar' => "baz", null => "xyz"); print_r(array_merge_recursive($a,$b)); print_(merge_old($a,$b)); print_(merge($a,$b)); function merge(array $a, array $b) { foreach ($b as $key => $value) { if (isset($a[$key])) { 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; } function merge_old(array $a, array $b) { foreach ($b as $key => $value) { if (array_key_exists($key, $a)) { if (is_int($key)) { $a[] = $value; } elseif (is_array($value) && is_array($a[$key])) { $a[$key] = merge_old($a[$key], $value); } else { $a[$key] = $value; } } else { $a[$key] = $value; } } return $a; }
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [foo] => xyz [] => Array ( [0] => abc [1] => xyz ) [bar] => baz ) Fatal error: Uncaught Error: Call to undefined function print_() in /in/dQ9iU:8 Stack trace: #0 {main} thrown in /in/dQ9iU on line 8
Process exited with code 255.

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