|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
7 + 20 = ?
Subscribe to this entry?

 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 10:01:31 2024 UTC