I have two arrays and I want to delete the same values between the two for example
$array1 = array(1,2,3,4,5,6)
$array2 = array(5,6,7,8,9,10)
would have the result
$array = array(1,2,3,4,7,8,9,10)
I tried
$array = array_unique(array_merge($array1, $array2));
But clearly that just deleted duplicates leaving the matched values, as single values. Is there a quick way to do this or will this have to be done using a function?
Sorry guys, clearly I don't understand arrays. Here are the actual arrays and result of suggestions at the bottom. result should be Coffee and General.
array(4) {
[0]=>
NULL
[1]=>
string(4) "Milk"
[3]=>
string(6) "Coffee"
[6]=>
string(8) "Sweetner"
}
array(4) {
[0]=>
NULL
[1]=>
string(8) "Sweetner"
[3]=>
string(4) "MIlk"
[9]=>
string(7) "General"
}
array(4) {
[1]=>
string(4) "Milk"
[2]=>
string(6) "Coffee"
[6]=>
string(4) "MIlk"
[7]=>
string(7) "General"
}
3in the resulting array?nullandSweetnerexist in both arrays and are properly filtered out. The rest are the unique values of both arrays.