How can I compare multidimensional arrays in php? Is there a simple way?
The simplest way I know:
$a == $b;
Note that you can also use the ===. The difference between them is:
===
With Double equals ==, order is important:
==
$a = array(0 => 'a', 1 => 'b'); $b = array(1 => 'b', 0 => 'a'); var_dump($a == $b); // true var_dump($a === $b); // false
With Triple equals ===, types matter:
$a = array(0, 1); $b = array('0', '1'); var_dump($a == $b); // true var_dump($a === $b); // false
Reference: Array operators
1.4m articles
1.4m replys
5 comments
56.9k users