The array intersection function in PHP that only compares values is "array_intersect()"; this function is used to compare the key values of two (or more) arrays, the syntax is "array_intersect(array1, array2. ..)" will return an intersection array containing values taken from the compared array (array 1).
The operating environment of this tutorial: Windows 7 system, PHP version 7.1, DELL G3 computer
The array intersection function in php that only compares values isarray_intersect()
.
array_intersect() function is used to compare two (or more) arrays. When comparing, only the key values of the arrays are compared and the intersection of the arrays is returned.
array_intersect(array1,array2,array3...);
array1,array2,array3...
is the array list that needs to be compared
Description | |
---|---|
array1 | Required. The first array to compare with other arrays.|
array2 | Required. The array to compare to the first array.|
array3,... | Optional. Additional array to compare with the first array.
"red","b"=>"green","c"=>"blue","d"=>"yellow"); $a2=array("e"=>"red","f"=>"black","g"=>"purple"); $a3=array("a"=>"red","b"=>"black","h"=>"yellow"); var_dump($a1); var_dump($a2); var_dump($a3); $result=array_intersect($a1,$a2,$a3); echo "交集数组:"; var_dump($result); ?>
PHP Video Tutorial"
The above is the detailed content of What is the array intersection function in php that only compares values?. For more information, please follow other related articles on the PHP Chinese website!