I need to combine some arrays in some other way, and I'm using array_merge_recursive. However, there is something that I need to change, and I do not know how to do it. Here is a quote from php.net
If, however, the arrays have the same digital key, a later value will not overwrite the original value, but will be added.
I want this value NOT to be added, I do not want to add the exact values ββto the new array. I hope you understand this.
Example:
$array = array( 'some' => array( 'other' => 'key', ), ); $array2 = array(); $array2['some']['other'] = 'key2';
If I use array_merge_recursive, this will result in the following:
Array ( [some] => Array ( [other] => Array ( [0] => key [1] => key2 ) ) )
I want it to match the same result, not add it. Yes, I know, you would say, and then use array_merge, but it does not work either. If I use this:
$array = array( 'some' => array( 'other' => 'key', ), ); $array2 = array(); $array2['some']['other2'] = 'key2'; print_r(array_merge($array, $array2));
It will remove $ array [some] [other] from the list and leave only $ array [some] [other2]. I do not know which is better, since no one does it better.
Alex emilov
source share