3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 7.0.0 - 7.3.0rc4
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.
Output for 5.1.0 - 5.6.28
Array ( [foo] => xyz [] => Array ( [0] => abc [1] => xyz ) [bar] => baz ) Fatal error: Call to undefined function print_() in /in/dQ9iU on line 8
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/dQ9iU on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/dQ9iU on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/dQ9iU on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/dQ9iU on line 12
Process exited with code 255.