YouTip LogoYouTip

Func Array Intersect Ukey

# PHP array_intersect_ukey() Function [![Image 3: PHP Array Reference](#)Complete PHP Array Reference](#) ## Example Compare the **keys** of two arrays (using a user-defined function to compare keys) and return the intersection: $b)?1:-1; } $a1=array("a"=>"red","b"=>"green","c"=>"blue"); $a2=array("a"=>"blue","b"=>"black","e"=>"blue"); $result=array_intersect_ukey($a1,$a2,"myfunction"); print_r($result); ?> [Run Example Β»](#) * * * ## Definition and Usage The array_intersect_ukey() function compares the **keys** of two (or more) arrays and returns 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 intersection array, which includes all keys that are present in the compared array (_array1_) and also in any other parameter arrays (_array2_ or _array3_ etc.). _array3_, etc. * * * ## Syntax array_intersect_ukey(_array1,array2,array3...,myfunction_) | Parameter | Description | | :--- | :--- | | _array1_ | Required. The first array to compare with. | | _array2_ | Required. The array to compare with the first array. | | _array3,..._ | Optional. More arrays to compare with the first array. | | _myfunction_ | Required. A string that defines a callable comparison function. The comparison function must return an integer 0 if the first argument is the second argument, respectively. | ## Technical Details | Return Value: | Returns an intersection array, which includes all keys that are present in the compared array (_array1_) and also in any other parameter arrays (_array2_ or _array3_ etc.). | | :--- | | 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: $b)?1:-1; } $a1=array("a"=>"red","b"=>"green","c"=>"blue"); $a2=array("a"=>"black","b"=>"yellow","d"=>"brown"); $a3=array("e"=>"purple","f"=>"white","a"=>"gold"); $result=array_intersect_ukey($a1,$a2,$a3,"myfunction"); print_r($result); ?> [Run Example Β»](#) * * Complete PHP Array Reference](#)
← Func Array Key ExistsJs Ex Browser β†’