lupu51nfactum N778 lupu51nfactum N778 - 1 month ago 21
PHP Question

PHP - array comparison == and ===

Can someone clarify please why is the result of

$a = array (0 => 1, 1 => 2, 2 => 3);
$b = array (1 => 2, 2 => 3, 0 => 1);
var_dump ($a === $b);


Boolean false and not Boolean true?

Answer

As you can see in the PHP manual

$a === $b: TRUE if $a and $b have the same key/value pairs in the same order and of the same types.

Your arrays key/value pairs are not set in the same order so the result will be false