Home >Backend Development >PHP Tutorial >php-Arrays function-array_intersect_uassoc-calculates the intersection of arrays with index check and compares the indexes with callback function_PHP tutorial

php-Arrays function-array_intersect_uassoc-calculates the intersection of arrays with index check and compares the indexes with callback function_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:51:071235browse

array_intersect_uassoc() calculates the intersection of arrays with index checking, and uses the callback function to compare the indexes

【Function】
This function will return an array,
This array contains all values ​​in array1 that are not in any other parameter array.
                           Note that unlike the array_intersect() function, key names are also used for comparison.
【Scope of use】
​​​​ php5.
【Use】
array array_intersect_assoc( array array1, array array2[,array...,callback key_compare_func] )
           array1/required/array1
           array2/required/comparable array must have at least one
           array.../optional/array used for comparison
            key_compare_func.../optional/provides users with a callback function as a comparison standard
【Example】
[php]
//Define two arrays respectively
$array1 = array( "blue" => 6, "red" => 2, "green" => 3, "purple" => 4 );
$array2 = array( "green"=>5 , "blue" => 6, "yellow" => 7, "cyan" => 8 );
print_r( array_intersect_uassoc( $array1, $array2, "strcasecmp" ) );
/*
Array
(
[blue] => 6
)
*/


Excerpted from zuodefeng’s notes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478209.htmlTechArticlearray_intersect_uassoc() Calculates the intersection of arrays with index checking, and uses the callback function to compare the indexes [Function] This function will return a Array, this array contains everything in array1 but...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn