PHP array_intersect_ukey() Function
Last Updated : 17 Mar 2025
The array_intersect_ukey( ) function Computes the intersection of arrays using a callback function on the keys for comparison. The function returns an array containing all the values of the first array which have matching keys that are present in all the arguments. This function was introduced in PHP 5.1.
Syntax
Parameter
| Parameter | Description | Is compulsory |
|---|---|---|
| array1 | The first array is the array that the others will be compared with. | compulsory |
| array2 | An array to be compared with the first array. | compulsory |
| array3 | An array to be compared with the first array. | Optional |
| user-defined-function | A string that defines a callable comparison function. The comparison function must return an integer <, =, or > than 0 if the first argument is <, =, or > than the second argument. | compulsory |
Return Type
This function returns the values of array1 whose keys exist in all the arguments.
EXAMPLE 1
Output:
Array ( [b] => Rohit )
EXAMPLE 2
Output:
Array ( [b] => Ball )
EXAMPLE 3
Output:
Array ( [a] => red )
EXAMPLE 4
Output:
Array ( [a] => red [b] => blue )
Next TopicPhp-array-key-exists-function