PHP array_uintersect_uassoc() Function
Last Updated : 17 Mar 2025
The array_uintersect_uassoc( ) is an inbuilt function of PHP. The array_uintersect_uassoc() function uses two user-defined functions to compare the keys and values of two or more arrays, and returns the matches. This function was introduced in PHP 5.0.
Syntax
Parameter
| Parameter | Description | Is compulsory |
|---|---|---|
| array1 | Array to compare from. | compulsory |
| array2 | Array to compare against. | compulsory |
| array3 | More arrays to compare against. | Optional |
| Value_compare_function | User defined function to compare values. | compulsory |
| Key_comapre_function | User defined function to compare keys. | compulsory |
Returns
The array_uintersect_uassoc( ) function returns an array containing the entries from array1 that are present in all the arguments.
Important note:
function_key and function_value must return an integer <,=, or > than 0 if the first argument is <,=,or > than the second argument.
Example 1
Output:
Array ( [a] => Apple [b] => Ball )
Example 2
Output:
Array ( [a] => PHP [b] => JAVA )
Example 3
Output:
Array
(
[1] => java
[3] => PHP
)
Example 4
Output:
Array
(
[a] => java
[b] =>php
)
Next TopicPhp-array-uksort-function