|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-05-02 17:28 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2014-05-02 17:28 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 15:00:01 2026 UTC |
Description: ------------ When using asort() with a boolean true value in any other position than the first item in an array, it breaks. Tried with versions 5.4.28 (Win7), 5.4.27 (Win7), 5.4.12 (Win7) and 5.4.10 (OSX) Test script: --------------- $tests = array( 'test_with_boolean_broken_1' => array('a', true, 'b', 'c'), 'test_with_boolean_broken_2' => array('a', 'b', 'c', true), 'test_with_boolean_working_1' => array(true, 'a', 'b', 'c'), 'test_without_boolean_working' => array('a', 1, 'b', 'c') ); foreach($tests as $test_name => $test_data) { echo '<h1>' . $test_name . '</h1>'; echo '<li>data 1 (unsorted):<pre>' . print_r($test_data, true) . '</pre>'; asort($test_data); echo '<li>data 2 (sorted):<pre>' . print_r($test_data, true) . '</pre>'; asort($test_data); echo '<li>data 3 (resorted 1):<pre>' . print_r($test_data, true) . '</pre>'; asort($test_data); echo '<li>data 4 (resorted 2):<pre>' . print_r($test_data, true) . '</pre>'; } Expected result: ---------------- When using: Array ( [0] => a [1] => 1 [2] => b [3] => c ) Result should be: Array ( [0] => a [2] => b [3] => c [1] => 1 ) Actual result: -------------- After asort() #1: Array ( [2] => b [3] => c [1] => 1 [0] => a ) After asort() #2: Array ( [0] => a [2] => b [3] => c [1] => 1 ) After asort() #3: Array ( [0] => a [1] => 1 [2] => b [3] => c )