#49698 [Opn]: Unexpected change in strnatcasecmp()
ID: 49698
Updated by: sjoerd@php.net
Reported By: sander dot vink at procurios dot nl
Status: Open
Bug Type: Strings related
Operating System: Linux
PHP Version: 5.2.11
New Comment:
This seems to be solved already in PHP 5.3-HEAD.
Previous Comments:
------------------------------------------------------------------------
[2009-09-28 07:56:04] sander dot vink at procurios dot nl
Description:
------------
We use the strnatcasecmp()-function to get a "natural order" in our
lists of items. Up until PHP 5.2.9 it worked like a charm, but since we
upgraded to PHP 5.2.11 the order seems to have been changed.
The natural order is used in our case to support the sorting of items
that have been prefixed with numbers (0, 1, 2, etc). This is exactly
where the problem arises: 0 should be "sorted" before 1, but this is no
longer the case.
This problem also occurs in the latest snapshot of PHP 5.3
Reproduce code:
---------------
<?php
$string1 = '0 Foo';
$string2 = '1 Bar';
var_dump(strnatcasecmp($string1, $string2));
Expected result:
----------------
int(-1)
Actual result:
--------------
int(1)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49698&edit=1
Thread (5 messages)