I see many answers about the way to remove duplicate keys after comparing two arrays.
But I'm trying to merge two arrays and remove duplicates arrays (I don't want to keep unique array).
For example I would like to compare the value of [Id]
key and delete the entire array if it exists in both arrays.
First array :
array(
[8] => Array (
[Id] => 200
[City] => New York
[Code] => AHSKDI
)
[15] => Array (
[Id] => 340
[City] => Paris
[Code] => ALDLPKZAKP
)
)
Second array :
array(
[7] => Array (
[Id] => 730
[City] => Tokyo
[Code] => AJJSJOOO
)
[10] => Array (
[Id] => 200
[City] => New York
[Code] => AHSKDI
)
)
I would like to remove definitively the array with [Id] => 200
array(
[0] => Array (
[Id] => 340
[City] => Paris
[Code] => ALDLPKZAKP
)
[1] => Array (
[Id] => 730
[City] => Tokyo
[Code] => AJJSJOOO
)
)
So first I use array_merge
and then I use array_unique
array_unique(array_merge($array1, $array2), SORT_REGULAR);
But array_unique
keep one of array duplicated and I don't want.
Is there another PHP function for this?
Thank you in advance