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] );
The array_uintersect() function returns an array that contains all values that exist in array1 and 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. A negative integer, zero, or a positive integer must be returned when the first parameter is considered to be less than, equal to, or greater than the second parameter.
This function returns an array containing all the values of array1 that exist in all parameters. Use callback functions to compare data.
Serial number | Parameters and descriptions |
---|---|
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 see <>/
Output result:
Array ( [a] => green [b] => brown [0] => red )