Opposite of array_intersect?

Itay Moav -Malimovka picture Itay Moav -Malimovka · Apr 7, 2011 · Viewed 37.7k times · Source

Is there a built-in function to get all members of array 1 which do not exist in array 2?
I know how to do it programatically, only wondering if there is a built-in function that does the same. So please, no code examples.

Answer

Jon picture Jon · Apr 7, 2011

That sounds like a job for array_diff.

Returns an array containing all the entries from array1 that are not present in any of the other arrays.