Bug #73232 [Opn]: Array ordering is inconsistant.

From: Date: Mon, 03 Oct 2016 18:13:18 +0000
Subject: Bug #73232 [Opn]: Array ordering is inconsistant.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204425@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73232&edit=1

 ID:                 73232
 Updated by:         cmb@php.net
 Reported by:        robin at patenall dot org dot uk
 Summary:            Array ordering is inconsistant.
 Status:             Open
 Type:               Bug
 Package:            Arrays related
 Operating System:   Centos
 PHP Version:        7.0.11
 Block user comment: N
 Private report:     N

 New Comment:

Well, what would you expect to be printed by

  var_dump($b < $a)


Previous Comments:
------------------------------------------------------------------------
[2016-10-03 09:54:45] robin at patenall dot org dot uk

Description:
------------
It appears that when comparing two arrays with the same keys but in different orders it is possible
for the first to be both less than and greater than the second. 

Test script:
---------------
<?php
$a = array("b" => 2, "a" => 4);
$b = array("a" => 3, "b" => 3);
/** $b = array("b" => 3, "a" => 3); This works correctly **/

if($a <  $b) echo "a is less than b\n";
if($a <= $b) echo "a is less than or equal to b\n";
if($a >  $b) echo "a is greater than b\n";
if($a >= $b) echo "a is greater than or equal to b\n";
if($a == $b) echo "a is equal to b\n";
if($a != $b) echo "a is not equal to b\n";


Expected result:
----------------
a is less than b
a is less than or equal to b
a is not equal to b


Actual result:
--------------
a is less than b
a is less than or equal to b
a is greater than b
a is greater than or equal to b
a is not equal to b


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=73232&edit=1


Thread (8 messages)

« previous php.bugs (#204425) next »