array_intersect() Definition and Usage
array_intersect() function returns the intersection array of two or more arrays.
The result array contains all values in the compared array that also appear in all other parameter arrays, and the key names remain unchanged.
Note: Only values are used for comparison.
Syntax
array_intersect(array1,array2,array3...)
参数 |
描述 |
array1 |
必需。与其他数组进行比较的第一个数组。 |
array2 |
必需。与第一个数组进行比较的数组。 |
array3 |
可选。与第一个数组进行比较的数组。可以有多个。 |
Example
Copy code The code is as follows:
$a1=array (0=>"Cat",1=>"Dog",2=>"Horse");
$a2=array(3=>"Horse",4=>"Dog", 5=>"Fish");
print_r(array_intersect($a1,$a2));
?>
Output:
Array ( [ 1] => Dog [2] => Horse )
http://www.bkjia.com/PHPjc/324563.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324563.htmlTechArticlearray_intersect() Definition and usage array_intersect() function returns the intersection array of two or more arrays. The result array contains everything in the compared array, and also appears in all other...