PHP判断两个数组是否存在交集的方法

WBOY
Release: 2016-06-20 13:03:41
Original
3008 people have browsed it

PHP判断两个数组是否存在交集,函数代码如下:

<p>/***************判断两个数组是否存在交集******************/</p>function get_array_intersection($array_A,$array_B){<br />	if(!isset($array_A) || !isset($array_B) || !is_array($array_A) || !is_array($array_B) || empty($array_A) || empty($array_B)){<br />		return false;<br />	}<br />	foreach($array_A as $temp){<br />		if(in_array($temp,$array_B)){<br />			return true;<br />		}<br />	}<br />	unset($array_A,$array_B,$temp);<br />	return false;<br />}
Copy after login


Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!