Req #76214 [NEW]: uasort different in different vesion

From: Date: Thu, 12 Apr 2018 11:55:25 +0000
Subject: Req #76214 [NEW]: uasort different in different vesion
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214713@lists.php.net to get a copy of this message
From:             gaozhenan at 126 dot com
Operating system: 
PHP version:      7.1.16
Package:          *General Issues
Bug Type:         Feature/Change Request
Bug description:uasort different in different vesion

Description:
------------
uasort's  problem  in different version(5.x, 7.x)

Test script:
---------------
<?php
$arr = array(
    38 => ['id' => 38, 'score' => 3.45],
    34 => ['id' => 34, 'score' => 3.45],
    30 => ['id' => 30, 'score' => 3.45],

);
uasort($arr, function ($row_a, $row_b) {                                
                                                                        
           
    if ($row_a['score'] == $row_b['score']) {
        return 0;
    }
    return ($row_a['score'] >= $row_b['score']) ? -1 : 1;
});

print_r($arr);
                                                                        
                                                                       

 ~/test/uasort.php[1]                                                   
                                                          
[gaozhenan@sjs_85_168 test]$php55 uasort.php 
Array
(
    [30] => Array
        (
            [id] => 30
            [score] => 3.45
        )

    [34] => Array
        (
            [id] => 34
            [score] => 3.45
        )

    [38] => Array
        (
            [id] => 38
            [score] => 3.45
        )

)
[gaozhenan@sjs_85_168 test]$php71 uasort.php   
Array
(
    [38] => Array
        (
            [id] => 38
            [score] => 3.45
        )

    [34] => Array
        (
            [id] => 34
            [score] => 3.45
        )

    [30] => Array
        (
            [id] => 30
            [score] => 3.45
        )

)

Expected result:
----------------
the result in php 7.x should be equal in 5.x

Actual result:
--------------
just opposite

-- 
Edit bug report at https://bugs.php.net/bug.php?id=76214&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=76214&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=76214&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=76214&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=76214&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=76214&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=76214&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=76214&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=76214&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=76214&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=76214&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=76214&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=76214&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=76214&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76214&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=76214&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=76214&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=76214&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76214&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=76214&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=76214&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#214713) next »