array_udiff

PHP 5, PHP 7, PHP 8
array_udiff - Computes the difference of arrays by using a callback function for data comparison
Manual
Code Examples

array_udiff( array$array, ... array$arrays, callable$value_compare_func ): array

Computes the difference of arrays by using a callback function for data comparison. This is unlike array_diff which uses an internal function for comparing the data.

Parameters

array

The first array.

arrays

Arrays to compare against.

value_compare_func

The callback comparison function.

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

callback(mixed$a,mixed$b ): int

Return Values

Returns an array containing all the values of array that are not present in any of the other arguments.

Notes

Note:

Please note that this function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using array_udiff($array1[0], $array2[0], "data_compare_func");.

Related Functions

Example of array_udiff

Show all examples for array_udiff

PHP Version: