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 performed through the user-provided callback function. A negative integer, zero, or a positive integer must be returned respectively when the first parameter is considered to be less than, equal to, or greater than the second parameter.
Note: Unlike array_uintersect(), the key names are also compared. The data is compared using a callback function.
Returns an array that contains all the values in the array1 values that also appear in all other parameter arrays.
Serial Number | Parameters and Description |
---|---|
1 | array1(Required) It specifies an array. |
2 | array2(Required) 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(Required) Name of the user-defined function. |
The array_uintersect_assoc function uses the strcasecmp function to compare keys and values, calculating 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 )