假设我们有:
$arr1 = array("a", "b");
$arr2 = array("a", "b");
并且数组始终排序。这是真的吗?
if ( $arr1 === $arr2 )
{
echo "condition met";
}
答案 0 :(得分:1)
您可以将两个(和更多)数组与array_diff()进行比较,并在您的情况下查找一个空数组。
$diff = array_diff($arr1, $arr2);
if(empty($diff)) {
echo "condition met";
}
答案 1 :(得分:1)
($arr1 == $arr2); // TRUE when both have the same key/value pairs.
($arr1 === $arr2); // TRUE when both have the same key/value pairs in the same order and of the same types.