English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The array_uintersect_assoc() function calculates the intersection of arrays with index checking, using a callback function to compare data
array_uintersect_assoc( $array1, $array2 [, $array3 ..., $data_compare_func] );
This comparison is made through the user-provided callback function. You must return an integer less than, equal to, or greater than zero if you think the first parameter is less than, equal to, or greater than the second parameter.
Note that unlike array_uintersect(), the key name is also compared. The data is compared using a callback function.
Returns an array that contains all the values that appear in the array1 The value also appears in all other parameter arrays.
Number | Parameters and Description |
---|---|
1 | array1(mandatory) It specifies an array. |
2 | array2(mandatory) It specifies the array to be compared with the first array. |
3 | array3(optional) It specifies the array to be compared with the first array. |
4 | data_compare_func(mandatory) Name of the user-defined function. |
array_uintersect_assoc uses the strcasecmp function to compare keys and values, and calculates the intersection of arrays
<?php $input1 = array("a"=>"green", "b"=>"brown", "c"=>"blue", "red"); $input2 = array("a"=>"GREEN", "B"=>"brown", "yellow", "red"); print_r(array_uintersect_assoc($input1, $input2, "strcasecmp")); ?>Test and see‹/›
Output result:
Array ( [a] => green )