标签:
原文地址http://www.jbxue.com/article/14703.html
// 快速的判断$a数组是否是$b数组的子集
$a = array(135,138);
$b = array(135,138,137);
方法1:
<?php
$flag = 1;
foreach ($a as $va) {
if (in_array($va, $b)) {
continue;
}else {
$flag = 0;
break;
}
}
if ($flag) {
echo "Yes";
}else {
echo "No";
}
方法2:
<?php
$c = array_diff($a, $b);
print_r($c);
$flag = empty($c)?1 : 0;
if ($flag) {
echo "Yes";
}else {
echo "No";
}
方法3:
<?php
if ($a == array_intersect($a, $b)) {
$flag = 1;
}else {
$flag = 0;
}
if ($flag) {
echo "Yes";
}else {
echo "No";
}
标签:
原文地址:http://www.cnblogs.com/firstForEver/p/4513650.html