fork(20) download
  1. <?php
  2.  
  3. $array1 = array('a' => 1, 'b' => 2, 'c' => 3);
  4. $array2 = array('d' => 4, 'e' => 5, 'f' => 6, 'a' => 'new value', '123' => 456);
  5.  
  6.  
  7. var_dump(array_replace_recursive($array1, $array2));
  8. ?>
  9.  
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
array(7) {
  ["a"]=>
  string(9) "new value"
  ["b"]=>
  int(2)
  ["c"]=>
  int(3)
  ["d"]=>
  int(4)
  ["e"]=>
  int(5)
  ["f"]=>
  int(6)
  [123]=>
  int(456)
}