array_intersect_ukey() function compares the keys of an array, checks with additional user-defined functions, and returns matching results. This function returns an array containing the entries in the first array that are present in all other arrays.
array_intersect_ukey(arr1, arr2, arr3, arr4, …, compare_func)
arr1 - The array to compare. Required.
arr2 - The array to compare. Required.
arr3 -You can add more arrays to compare. Optional.
arr4 - You can add more arrays to compare. Optional.
compare_func - If the first argument is considered <,则此回调函数必须返回一个小于 0 的整数 <、= 或 > , = or > respectively instead of the second.
array_intersect_ukey() function returns an array containing the entries present in the first array in all other arrays.
The following is an example of comparing keys.
Real-time demonstration
<?php function check($a,$b) { if ($a===$b) { return 0; } return ($a>$b)?1:-1; } $arr1 = array("a"=>"one","b"=>"two","c"=>"three"); $arr2 = array("a"=>"one","b"=>"two"); $result = array_intersect_ukey($arr1,$arr2,"check"); print_r($result); ?>
Array ( [a] => one [b] => two )
The above is the detailed content of array_entersect_ukey() function in PHP. For more information, please follow other related articles on the PHP Chinese website!