3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array1 = ['foo' => ['a' => 1, 'b' => 2], 'bar' => 1]; $array2 = ['foo' => ['c' => 3, 'a' => 4, 'd' => 4], 'bar' => 2]; var_dump(array_replace_recursive($array1, $array2));
based on qUmBE
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0alpha1
array(2) { ["foo"]=> array(4) { ["a"]=> int(4) ["b"]=> int(2) ["c"]=> int(3) ["d"]=> int(4) } ["bar"]=> int(2) }