array_diff

PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8
array_diff - Computes the difference of arrays

array_diff( array$array, ... array$arrays ): array

Compares array against one or more other arrays and returns the values in array that are not present in any of the other arrays.

Parameters

array

The array to compare from

arrays

Arrays to compare against

Return Values

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

Notes

Note:

This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using array_diff($array1[0], $array2[0]);.

Related Functions

Example of array_diff

Show all examples for array_diff

PHP Version: