Doc #75444 [Opn->Nab]: Array comparison operators unprecise

From: Date: Thu, 26 Oct 2017 08:25:24 +0000
Subject: Doc #75444 [Opn->Nab]: Array comparison operators unprecise
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15185@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75444&edit=1 ID: 75444 Updated by: pmmaga@php.net Reported by: kvanderheijden at transip dot nl Summary: Array comparison operators unprecise -Status: Open +Status: Not a bug Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php 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: https://3v4l.org/EZv8I Previous Comments: ------------------------------------------------------------------------ [2017-10-26 08:12:51] kvanderheijden at transip dot nl Description: ------------ On the PHP documentation page about array operators, the equality tests operators are misleading. See: http://us2.php.net/manual/en/language.operators.array.php 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75444&edit=1

« previous php.doc.bugs (#15185) next »