|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70850 error in summary of array comparison
Submitted: 2015-11-03 21:53 UTC Modified: 2017-01-28 13:53 UTC
From: JQKP at example dot com Assigned:
Status: Verified Package: Arrays related
PHP Version: 5.6.15 OS: MS Windows
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: JQKP at example dot com
New email:
PHP Version: OS:


 [2015-11-03 21:53 UTC] JQKP at example dot com
From manual page:

> Array with fewer members is smaller, if
> key from operand 1 is not found in operand
> 2 then arrays are uncomparable, otherwise
> - compare value by value

This is not true. See my test script below.

(However, the "Example #2 Transcription of standard array comparison" on the manual page does seem to be true.)

Test script:
print $a<$b;
# This prints 1 because it compares the first keys.
# However, according to the manual, as quoted above,
# it should print '' because "key from operand 1
# [namely 2] is not found in operand 2".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-03 22:57 UTC]
It's not so much wrong as it is unclear how the comparison works. It doesn't check all the keys in operand 1 against those in operand 2 and *then* do the value comparison. Rather, as it loops through operand 1 it first checks that operand 2 has the key before trying to compare their two values.
 [2017-01-28 13:53 UTC]
-Status: Open +Status: Verified -Package: Documentation problem +Package: Arrays related
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Mar 25 11:03:44 2023 UTC