Bug #70770 [Opn->Ana]: Natsort: different results for PHP5 and PHP7

From: Date: Thu, 22 Oct 2015 16:01:39 +0000
Subject: Bug #70770 [Opn->Ana]: Natsort: different results for PHP5 and PHP7
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196749@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70770&edit=1 ID: 70770 Updated by: rasmus@php.net Reported by: tronsha at gmx dot de Summary: Natsort: different results for PHP5 and PHP7 -Status: Open +Status: Analyzed Type: Bug Package: *General Issues PHP Version: 7.0Git-2015-10-22 (Git) Block user comment: N Private report: N New Comment: This is likely because 09 and 009 are actually equivalent in a natural sort and the backend sorting algorithm has changed and the order of equivalent elements don't always match the old algorithm. Both outputs are correct there as far as I am concerned. Previous Comments: ------------------------------------------------------------------------ [2015-10-22 13:41:54] tronsha at gmx dot de Description: ------------ --- From manual page: http://www.php.net/function.natsort --- I get different results for PHP5 and PHP7 PHP 5 Array ( [5] => 0 [1] => 8 [3] => 009 [0] => 09 [2] => 10 [4] => 011 ) PHP 7 (dev) Array ( [5] => 0 [1] => 8 [0] => 09 [3] => 009 [2] => 10 [4] => 011 ) Test script: --------------- <?php $zeros = array('09', '8', '10', '009', '011', '0'); natsort($zeros); print_r($zeros); Expected result: ---------------- Array ( [5] => 0 [1] => 8 [3] => 009 [0] => 09 [2] => 10 [4] => 011 ) Actual result: -------------- Array ( [5] => 0 [1] => 8 [0] => 09 [3] => 009 [2] => 10 [4] => 011 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70770&edit=1

« previous php.bugs (#196749) next »