Easy Tutorial
❮ Func String Stripos Pdostatement Columncount ❯

PHP array_udiff() Function

Complete PHP Array Reference Manual

Example

Compare the values of two arrays (using a user-defined function to compare values) and return the difference:


Definition and Usage

The array_udiff() function is used to compare the values of two (or more) arrays and return the difference.

Note: This function uses a user-defined function to compare values!

This function compares the values of two (or more) arrays and returns an array containing all the values from the first array that are not present in any of the other arrays.


Syntax

Parameter Description
array1 Required. The first array to compare with other arrays.
array2 Required. An array to compare against the first array.
array3,... Optional. Additional arrays to compare against the first array.
myfunction Required. A string defining a callable 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.

Technical Details

Return Value: Returns an array containing all the values from the first array that are not present in any of the other arrays.
PHP Version: 5.1.0+
--- ---

More Examples

Example 1

Compare the values of three arrays (using a user-defined function to compare values) and return the difference:


❮ Func String Stripos Pdostatement Columncount ❯