|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-04-12 12:18 UTC] danack@php.net
-Status: Open
+Status: Not a bug
[2018-04-12 12:18 UTC] danack@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 05:00:01 2025 UTC |
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