note 32610 added to function.natcasesort
| From: | dslicer at maine dot rr dot com | Date: | Mon, 02 Jun 2003 23:41:16 +0000 |
| Subject: | note 32610 added to function.natcasesort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49589@lists.php.net to get a copy of this message | ||
Something that should probably be documented is the fact that both natsort and natcasesort maintain
the key-value associations of the array. If you natsort a numerically indexed array, a for loop will
not produce the sorted order; a foreach loop, however, will produce the sorted order, but the
indices won't be in numeric order. If you want natsort and natcasesort to break the key-value
associations, just use array_values on the sorted array, like so:
natcasesort($arr);
$arr = array_values($arr);
----
Manual Page -- http://www.php.net/manual/en/function.natcasesort.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32610
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32610&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32610&report=yes