Comparing Arrays And Object¶
== and === apply different algorithms to compare arrays.
== compares keys without taking order in account, while === also takes into account the order.
== applies type juggling to values, and then compare them loosely, while === makes a identity comparison, with value and type. == and === compare keys the same way, as they can only be int or string, and no type-juggling is applied.
The same rules apply when comparing objects: the order of assignations of the properties is used by == but not by ===.
Finally, comparing an array and an object always fails: one of them has to be cast.
See Also¶
Comparing arrays [Try me]
Comparing object [Try me]