Easy Tutorial
❮ Func Mysqli Get Server Version Func Math Acosh ❯

PHP array_intersect_ukey() Function

Complete PHP Array Reference Manual

Example

Compare the keys of two arrays (using a user-defined function to compare keys) and return the intersection:


Definition and Usage

The array_intersect_ukey() function is used to compare the keys of two (or more) arrays and return the intersection.

Note: This function uses a user-defined function to compare keys!

This function compares the keys of two (or more) arrays and returns an array of intersecting keys. This array includes all keys present in the first array (array1) that are also present in any of the other parameter arrays (array2 or array3, etc.).


Syntax

Parameter Description
array1 Required. The first array to compare with other arrays.
array2 Required. An array to compare against the first array.
array3,... Optional. Additional arrays to compare against the first array.
myfunction Required. A string defining a callable comparison function. The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

Technical Details

Return Value: Returns an array containing all the keys from array1 that are present in all of the other arrays.
PHP Version: 5.1.0+
--- ---

More Examples

Example 1

Compare the keys of three arrays (using a user-defined function to compare keys) and return the intersection:


❮ Func Mysqli Get Server Version Func Math Acosh ❯