I have two associative array which have many content same and so I want to combine those two arrays in such a way that if I have a
in array 1 and a
array_merge()
will override duplicates only if both arrays contain the same string keys:
If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.
I believe this behavior is expected. How would you handle this case? Let's say that
$arr1 = array('a' => 1);
$arr2 = array('a' => 2);
What would be an acceptable output after the array merge?