note 103139 added to collator.asort
| From: | jeff_walter at kace dot com | Date: | Mon, 28 Mar 2011 17:33:29 +0000 |
| Subject: | note 103139 added to collator.asort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178273@lists.php.net to get a copy of this message | ||
The above post doesn't work. This example does..
function natsortIntl($number) {
return sprintf('%032d', $number);
}
function sortIntl($array, $natural = true) {
$data = $array;
if ($natural === true) {
$data = preg_replace_callback('~([0-9]+)~', 'natsortIntl', $data);
}
collator_asort(collator_create('root'), $data);
return array_intersect_key($data, $array); <--- This is correct.
}
----
Server IP: 69.147.83.197
Probable Submitter: 173.174.241.172
----
Manual Page -- http://www.php.net/manual/en/collator.asort.php
Edit -- https://master.php.net/note/edit/103139
Del: integrated -- https://master.php.net/note/delete/103139/integrated
Del: useless -- https://master.php.net/note/delete/103139/useless
Del: bad code -- https://master.php.net/note/delete/103139/bad+code
Del: spam -- https://master.php.net/note/delete/103139/spam
Del: non-english -- https://master.php.net/note/delete/103139/non-english
Del: in docs -- https://master.php.net/note/delete/103139/in+docs
Del: other reasons-- https://master.php.net/note/delete/103139
Reject -- https://master.php.net/note/reject/103139
Search -- https://master.php.net/manage/user-notes.php