Ref: https://stackoverflow.com/questions/17462354/how-to-merge-array-and-preserve-keys/17462587
You're looking for array_replace():
Available since PHP 5.3.
You can also use the union array operator; it works for older versions and might actually be faster too:
print_r($array2 + $array1);
$array1 = array('a' => 1, 'b' => 2, 'c' => 3);
$array2 = array('d' => 4, 'e' => 5, 'f' => 6, 'a' => 'new value', '123' => 456);
//array_replace
print_r(array_replace($array1, $array2));
//UNION
print_r($array2 + $array1);