Home > php教程 > PHP源码 > array_intersect:根据值计算多个数组的交集

array_intersect:根据值计算多个数组的交集

PHP中文网
Release: 2016-05-23 16:39:13
Original
1013 people have browsed it

array_intersect:根据值计算多个数组的交集

array array_intersect ( array $array1 , array $array2 [, array $ ... ] )
返回一个数组,该数组的值在每个数组都有

$arr1 = ['a'=>'aaa','b'=>'bbb','c'=>'ccc'];
$arr2 = ['bb'=>'ccc','dd'=>'aaa'];
$arr = array_intersect($arr1, $arr2);
 
echo &#39;<pre class="brush:php;toolbar:false">&#39;;
print_r($arr);
 
result:
Array
(
    [a] => aaa
    [c] => ccc
)
Copy after login

 以上就是array_intersect:根据值计算多个数组的交集的内容,更多相关内容请关注PHP中文网(www.php.cn)! 


source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template