PHP :: Bug #49698 :: Unexpected change in strnatcasecmp()
| Bug #49698 | Unexpected change in strnatcasecmp() | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2009-09-28 07:56 UTC | Modified: | 2009-09-28 13:31 UTC |
|
||||||||||
| From: | sander dot vink at procurios dot nl | Assigned: | ||||||||||||
| Status: | Closed | Package: | Strings related | |||||||||||
| PHP Version: | 5.2.11 | OS: | Linux | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2009-09-28 07:56 UTC] 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)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-09-28 11:22 UTC] sjoerd@php.net
[2009-09-28 11:49 UTC] sander dot vink at procurios dot nl
[2009-09-28 11:51 UTC] sander dot vink at procurios dot nl
[2009-09-28 13:31 UTC] rasmus@php.net