Use array_diff()
:
$result = array_diff($array2, $array1);
Note that the order of arguments is important here. The above statement checks $array2
against $array1
and returns the values in $array2
that are not present in $array1
.
Output:
Array
(
[2] => 4
[4] => 6
[5] => 7
)