English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The array_uintersect() function calculates the intersection of arrays, comparing data using a callback function
array_uintersect ( $array1, $array2 [, $array3 ..., $data_compare_func] );
array_uintersect() returns an array that contains all in array1 Also appear in all other parameter arrays. Data comparison is done using a callback function. This comparison is done through the callback function provided by the user. 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.
This function returns an array containing all array1All values. Use callback function to compare data.
Serial Number | Parameters and Description |
---|---|
1 | array1 Required. Specify an array. |
2 | array2 Required. Specify the array to be compared with the first array. |
3 | array3 Optional. Specify the array to be compared with the first array. |
4 | data_compare_func Required. The name of the user-defined function. |
Use the built-in function strcasecmp as the callback function to calculate the intersection of two arrays
<?php $array1 = array("a"=>"green", "b"=>"brown", "c"=>"blue", "red"); $array2 = array("a"=>"GREEN", "B"=>"brown", "yellow", "red"); print_r(array_uintersect($array1, $array2, "strcasecmp")); ?>Test and see‹/›
Output Result:
Array ( [a] => green [b] => brown [0] => red )