note 103138 added to collator.asort

From: Date: Mon, 28 Mar 2011 17:29:42 +0000
Subject: note 103138 added to collator.asort
Groups: php.notes 
Request: Send a blank email to php-notes+get-178271@lists.php.net to get a copy of this message
The above example has a bug. Should be: 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/103138 Del: integrated -- https://master.php.net/note/delete/103138/integrated Del: useless -- https://master.php.net/note/delete/103138/useless Del: bad code -- https://master.php.net/note/delete/103138/bad+code Del: spam -- https://master.php.net/note/delete/103138/spam Del: non-english -- https://master.php.net/note/delete/103138/non-english Del: in docs -- https://master.php.net/note/delete/103138/in+docs Del: other reasons-- https://master.php.net/note/delete/103138 Reject -- https://master.php.net/note/reject/103138 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178271) next »