cruim Asked:2020-04-26 23:20:23 +0800 CST2020-04-26 23:20:23 +0800 CST 2020-04-26 23:20:23 +0800 CST 在两个数组中查找相同的元素 772 有两个数组$first = ['one','two','three'];$second= ['five','four','three']; 问题是如何检查相同的元素,比如 if(in_array($first,$second)){ echo 'yes'} else {echo 'no'} php 1 个回答 Voted Best Answer etki 2020-04-26T23:23:39+08:002020-04-26T23:23:39+08:00 数组相交:array_intersect $intersection = array_intersect(['one', 'two', 'three'], ['five', 'four', 'three']); // ['three'] 之后,剩下的就是使用上面的in_array来查找交集的元素了: if (in_array('three', $intersection)) ...
数组相交:array_intersect
之后,剩下的就是使用上面的in_array来查找交集的元素了: