|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2004-02-04 19:29 UTC] sniper@php.net
  [2004-02-05 14:30 UTC] tomas dot matousek at matfyz dot cz
  [2004-02-05 16:28 UTC] andrey@php.net
  [2004-02-05 16:49 UTC] tomas dot matousek at matfyz dot cz
  [2004-02-06 11:19 UTC] sniper@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 15:00:01 2025 UTC | 
Description: ------------ The way in which elements of an array are compared is inconsistent. Reproduce code: --------------- $a = $c = array("101a","100","6"); $b = $d = array("100","6","101a"); // standard comparison: $f = create_function('$a,$b','return ($a<$b) ? -1:($a>$b ? +1:0);'); asort($a); asort($b); uasort($c,$f); uasort($d,$f); print_r($a); print_r($b); print_r($c); print_r($d); Expected result: ---------------- Than I would expect all 'print_r' print arrays with the same order of values. I would expect that items implicitly converted into numbers during comparison should precede those of type string. Actual result: -------------- Array ( [2] => 6 [1] => 100 [0] => 101a ) Array ( [2] => 101a [1] => 6 [0] => 100 ) Array ( [2] => 6 [1] => 100 [0] => 101a ) Array ( [2] => 101a [1] => 6 [0] => 100 )