PHP array_udiff() Function
Last Updated : 17 Mar 2025
The array_udiff( ) function is an inbuilt function of PHP. The array_udiff( ) function is used to compute the difference of given arrays by using a callback function for data comparison. This function was introduced in PHP 5.1.0.
Syntax
Parameters
| Parameter | Description | Is compulsory |
|---|---|---|
| array1 | The first Array. | compulsory |
| array2 | Array to compare against. | compulsory |
| array3,... | More arrays to compare against. | Optional |
| Value_compare_function | A string that define a callable comparison function. | compulsory |
Return Values
The array_udiff( ) function returns an array containing the entries from array1 that are not present in any of the other arrays.
Important note:
User-defined function must returns an integer <, =, or > than 0 if the first argument is <, =, or > than the second argument.
Example 1
Output:
Array
(
[a] => A
[b] => HTML
[c] =>javatpoint
)
Example 2
Output:
Array
(
[c] => ruby
)
Example 3
Output:
Array
(
[d] => Java
[r] => HTML
)
Example 4
Output:
Array
(
[a] =>bengaluru
[b] =>chennai
)
Next TopicPhp-array-udiff-uassoc-function