PHP array_intersect_ukey() Function

PHP array_intersect_ukey Function


Defintion :

The array_intersect_ukey() function compares the keys of two or more arrays and returns the matches or intersection using a user-defined key comparison function.

Also, the values for the keys are not considered in the comparison, only the keys are checked.

This function compares the keys of two or more arrays, and return an array that contains the entries from array1 that are present in array2array3, etc.

Syntax

The basic syntax of the array_intersect_ukey() function is given with:

  array_intersect_ukey(array1array2...key_compare_function);

Parameters

The array_intersect_ukey() function accepts the following parameters.

Parameter Description
array1 Required. Specifies the array to compare from.
array2 Required. Specifies an array to compare keys against.
... Optional. Specifies more arrays to compare keys against.
key_compare_function Required. Specifies a callback function to use for key comparison.

 

Example1:

Following example compare the keys of two arrays (using a user-defined key comparison function), and return the matches:

Output :

Array
(
    [a] => Web
    [b] => designing
)

Example2 :

Following example Compare the keys of three arrays (use a user-defined function to compare the keys), and return the matches:

Output :

Array
(
    [a] => Web
    [b] => designing
    [c] => house
)