PHP:检查一个数组是否包含另一个数组中的所有数组值 [英] PHP: Check if an array contains all array values from another array
本文介绍了PHP:检查一个数组是否包含另一个数组中的所有数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$all = array
(
0 => 307,
1 => 157,
2 => 234,
3 => 200,
4 => 322,
5 => 324
);
$search_this = array
(
0 => 200,
1 => 234
);
我想知道 $all
是否包含所有 $search_this
值并返回 true
或 false
.请问有什么想法吗?
I would like to find out if $all
contains all $search_this
values and return true
or false
. Any ideas please?
推荐答案
$containsSearch = count(array_intersect($search_this, $all)) === count($search_this);
这篇关于PHP:检查一个数组是否包含另一个数组中的所有数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文