php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2689 asort behaviour changed over the week-end ?
Submitted: 1999-11-09 13:53 UTC Modified: 1999-11-10 02:49 UTC
From: Danny dot Heijl at cevi dot be Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Latest CVS (09/11/1999) OS: RH 6.0 Linux
Private report: No CVE-ID: None
 [1999-11-09 13:53 UTC] Danny dot Heijl at cevi dot be
The following script : 
<?php 
$a[0] = 1;
$a[r] = 2;
$a[4] = 3;
$a[c] = three;
$a[d] = one;
$a[a] = two;
?>
Before being sorted
-------------------
<?php 
reset($a);
$b = current($a);
while ($b != "") {
    echo "\$a[" . key($a) . "]=$b\n";
    $b = next($a);
}
asort($a);
?>
After being sorted
-------------------
<?php 
reset($a);
$b = current($a);
while ($b != "") {
    echo "\$a[" . key($a) . "]=$b\n";
    $b = next($a);
}
?>

gives the following output : 
Content-Type: text/html

Before being sorted
-------------------
$a[0]=1
$a[r]=2
$a[4]=3
$a[c]=three
$a[d]=one
$a[a]=two
After being sorted
-------------------
$a[d]=one
$a[c]=three
$a[a]=two
$a[0]=1
$a[r]=2
$a[4]=3

While last week it produced (and so does php3 3.0.12) :

Content-Type: text/html

Before being sorted
-------------------
$a[0]=1
$a[r]=2
$a[4]=3
$a[c]=three
$a[d]=one
$a[a]=two
After being sorted
-------------------
$a[0]=1
$a[r]=2
$a[4]=3
$a[d]=one
$a[c]=three
$a[a]=two

Danny
---

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-11-10 02:49 UTC] thies at cvs dot php dot net
in php3:

if (1 < "hallo")  // is FALSE
but 
$m = min(1,"hallo"); // $m is 1

so in this case php is inconsistent with itself (i would classify *this* as a bug in php3) -

we changed this a few days ago on purpose in PHP 4 to make the language consistent with itself!

(but i can see your point, and i'm not too happy about it)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC