php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49797 strnatcmp and strings ending with 0
Submitted: 2009-10-06 21:55 UTC Modified: 2009-10-07 11:29 UTC
From: j dot henge-ernst at interexa dot de Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.3.0 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: j dot henge-ernst at interexa dot de
New email:
PHP Version: OS:

 

 [2009-10-06 21:55 UTC] j dot henge-ernst at interexa dot de
Description:
------------
strnatcmp returns wrong results when one string is ending with a zero. At leat in php 5.2.9 the expected result is returned. In php 5.3.0 and 5.2.10 it is broken.

Reproduce code:
---------------
<?php
echo strnatcmp('b0',  'b0$')  . "\n";
echo strnatcmp('b1',  'b1$')  . "\n";
echo strnatcmp('b0x', 'b0x$') . "\n";

echo strnatcasecmp('b0',  'B0$')  . "\n";
echo strnatcasecmp('b1',  'B1$')  . "\n";
echo strnatcasecmp('b0x', 'B0x$') . "\n";


Expected result:
----------------
-1
-1
-1
-1
-1
-1

Actual result:
--------------
1
-1
-1
1
-1
-1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-07 08:13 UTC] pajoye@php.net
Pls see #44929 and try a snapshot as well.
 [2009-10-07 09:59 UTC] j dot henge-ernst at interexa dot de
Snapshot php53-200910070830 and php52-200910070830 work as expected
 [2009-10-07 11:29 UTC] pajoye@php.net
duplicate of #44929, which is fixed > bogus.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC