|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75444 Array comparison operators unprecise
Submitted: 2017-10-26 08:12 UTC Modified: 2017-11-03 15:10 UTC
From: kvanderheijden at transip dot nl Assigned: pmmaga (profile)
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kvanderheijden at transip dot nl
New email:
PHP Version: OS:


 [2017-10-26 08:12 UTC] kvanderheijden at transip dot nl
On the PHP documentation page about array operators, the equality tests operators are misleading. See:

The docs say that the Identity comparison operator '===' checks the order of the elements, whereas there is no such mention on the Equality comparison operator.

This would imply that the order does not matter when comparing array's with the Equality operator. This is incorrect.

Test script:
$a = [1, 2, 3];
$b = [1, 3, 2];

echo '$a == $b: ', ($a == $b ? 'TRUE' : 'FALSE'), PHP_EOL;
echo '$a === $b: ', ($a === $b ? 'TRUE' : 'FALSE'), PHP_EOL;

Expected result:
$a == $b: TRUE
$a === $b: FALSE

Actual result:
$a == $b: FALSE
$a === $b: FALSE


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-26 08:25 UTC]
-Status: Open +Status: Not a bug
 [2017-10-26 08:25 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

As the documentation states, it should only be true if both the keys and the values are the same. That is not the case in your example. The keys are not the same. Check this example:
 [2017-11-03 15:10 UTC]
-Assigned To: +Assigned To: pmmaga
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Oct 30 16:01:23 2020 UTC