Edit report at http://bugs.php.net/bug.php?id=54530&edit=1

 ID:                 54530
 Updated by:         ahar...@php.net
 Reported by:        chatfielddaniel at googlemail dot com
 Summary:            strnatcasecmp treats alphanumeric values before
                     symbols
-Status:             Open
+Status:             Bogus
 Type:               Bug
-Package:            Unknown/Other Function
+Package:            Strings related
 Operating System:   Windows 7
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Just like all of the other comparison functions, strnatcmp() and
strnatcasecmp() eventually fall back to a straight byte value by byte
value comparison if the "natural" alphanumeric sorting logic isn't
triggered. Since the underscore character has a higher character code
than any number or uppercase letter (and case-insensitive comparisons
are done on uppercased strings), it's always "after" letters and
numbers.



This behaviour isn't going to change.


Previous Comments:
------------------------------------------------------------------------
[2011-04-14 12:59:37] chatfielddaniel at googlemail dot com

Description:
------------
---

>From manual page: http://www.php.net/function.strnatcasecmp

---

The strnatcasecmp is set that '_' is after letters and numbers which is
illogical 

and should be changed.

Test script:
---------------
echo strnatcasecmp('1','2');//-1

echo strnatcasecmp('_','2');//1 (incorrect)

echo strnatcasecmp('_','a');//1 (incorrect)

echo strnatcasecmp('a','b');//-1

echo strnatcasecmp(2,'a');//-1



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54530&edit=1

Reply via email to