|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-06-13 15:09 UTC] felipe@php.net
-Status: Assigned
+Status: Wont fix
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 20 20:00:01 2025 UTC |
Description: ------------ According to the documentation for sort(), you must use i18n_loc_set_default() for sort() with SORT_LOCALE_STRING to work in PHP6. However, i18n_loc_set_default() is an undefined function. The documentation instead refers to locale_set_default(). When setting the locale to "sv_SE" (correct) the function returns false, but when setting it to "sv_PHP" (incorrect) the function returns true which is the wrong behavior. The example from locale_set_default() uses "pt_PT" which can be set, but when sorting the result turns out the wrong way. When using locale_get_default() it returns what was set with locale_set_default() even if that function turned it down by returning false. When later using sort() or asort() (or any other sort) with SORT_LOCALE_STRING the result is the same as a normal sort. Reproduce code: --------------- <?php //Code from the documentation for locale_set_default() // the list of the strings to sort $array = array( 'caramelo', 'cacto', 'ca?ada' ); // set our locale (Portuguese, in this case) locale_set_default('pt_PT'); // sort using the locale we previously set sort($array, SORT_LOCALE_STRING); print_r($array); ?> Expected result: ---------------- Array ( [0] => ca?ada [1] => cacto [2] => caramelo ) Actual result: -------------- Array ( [0] => cacto [1] => caramelo [2] => ca?ada )