如何在不删除第一个数组中的不匹配键的情况下用另一个数组替换数组?

Array1:

array('key01'=>321312, 'key03'=>23)

Array2:

array('key01'=>22, 'key04'=>78, 'key05'=>54)

I'm trying to to replace the values if array1 with the values of array2 and leaving any keys untouched that are not in array2.

So the outcome would be:

array('key01'=>22, 'key03'=>23, 'key04'=>78, 'key05'=>54)

You can use array_merge:

$a1 = array('key01'=>321312, 'key03'=>23);
$a2 = array('key01'=>22, 'key04'=>78, 'key05'=>54);
print_r(array_merge($a1,$a2));
$arr1 = $arr2 + $arr1;

The keys will remain as you said:

$arr1 = array('key01'=>22, 'key04'=>78, 'key05'=>54, 'key03'=>23);

But the order is important. In the case above, $arr2, being first, will overwrite values with the same key of $arr1.