Reputation: 11106
Supposed we have:
$arr1 = array("a", "b");
$arr2 = array("a", "b");
and arrays are always sorted. Is this true:
if ( $arr1 === $arr2 )
{
echo "condition met";
}
Upvotes: 0
Views: 41
Reputation: 7705
($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.
Upvotes: 1
Reputation: 4680
You can compare two (and more) arrays with array_diff() and look for an empty array, in your case.
$diff = array_diff($arr1, $arr2);
if(empty($diff)) {
echo "condition met";
}
Upvotes: 1