note 125314 added to function.asort

From: Date: Mon, 31 Aug 2020 19:49:02 +0000
Subject: note 125314 added to function.asort
Groups: php.notes 
Request: Send a blank email to php-notes+get-215050@lists.php.net to get a copy of this message
'asort' is fine for sorting arrays in English, but if accented characters exist in the array then it is better to use the 'asort' method of PHP's Collator class: https://www.php.net/manual/en/class.collator.php $collator = new \Collator('fr_CA'); $collator->asort($french_list); There are options for using setlocale() to control asort behaviour, but it isn't reliable across systems. For instance, in my development environment I only have access to the following locals: $ locale -a C C.UTF-8 POSIX ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.167.36 (proxied: 161.216.47.233) ---- Manual Page -- http://php.net/manual/en/function.asort.php Edit -- https://master.php.net/note/edit/125314 Del: integrated -- https://master.php.net/note/delete/125314/integrated Del: useless -- https://master.php.net/note/delete/125314/useless Del: bad code -- https://master.php.net/note/delete/125314/bad+code Del: spam -- https://master.php.net/note/delete/125314/spam Del: non-english -- https://master.php.net/note/delete/125314/non-english Del: in docs -- https://master.php.net/note/delete/125314/in+docs Del: other reasons-- https://master.php.net/note/delete/125314 Reject -- https://master.php.net/note/reject/125314 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#215050) next »