PHP array_diff_uassoc() Function
Last Updated : 17 Mar 2025
This function is inbuilt in PHP and it was introduced in PHP 5. The function array_diff_uassoc() is used to compute the difference of arrays with additional index check which is performed by a user supplied callback function.
In simple words, the function compares array1 against array2 and returns the difference.
Syntax
| Parameter | Description | Is compulsory |
|---|---|---|
| array1 | The array to compare from | compulsory |
| array2 | An array to compare against | compulsory |
| array3 | More arrays to compare against | Optional |
| User defined function | The specified callback function. The function returns an integer less than, equal to or greater than zero. | compulsory |
Important note: This function uses a user-defined function to compare the keys.
Return Type
This function returns an array containing the entries from array1 that are not present in any of the other ways.
Example 1
Output:
Array( [10] => sid [20] => raj )
Example 2
Output:
Array ( [b] => brown [c] => blue [0] => red )
Example 3
Output:
Array ( [c] => orange )
Example 4
Output:
Array ( [b] => brown [c] => blue [0] => red )
Next TopicPhp-array-diff-ukey-function