Home > php教程 > php手册 > PHP数组对比函数,存在交集则返回真,否则返回假

PHP数组对比函数,存在交集则返回真,否则返回假

WBOY
Release: 2016-06-06 20:36:04
Original
1138 people have browsed it

PHP数组对比函数,存在交集则返回真,否则返回假,需要的朋友可以参考下。

复制代码 代码如下:


$array1 = array('a', 'b', 'c', 'd');
$array2 = array('a', 'c');
$array3 = array_intersect($array1, $array2);
if($array3) {
echo '有交集';
}
?>

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template