note 30757 added to function.sort
| From: | Rich at rack1 dot php dot net | Date: | Thu, 27 Mar 2003 16:28:18 +0000 |
| Subject: | note 30757 added to function.sort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45910@lists.php.net to get a copy of this message | ||
Trying to sort an array without regard to case (case insensitive?) Try usort(). I needed to sort
an associated array without regard to case and this is what I came up with, from modifying the
example from the documentation for usort().
function cmp ($a, $b)
{
return strcasecmp($a["field_name"], $b["field_name"]);
}
uasort($array, "cmp");
-RIch
--
http://www.php.net/manual/en/function.sort.php
http://master.php.net/manage/user-notes.php?action=edit+30757
http://master.php.net/manage/user-notes.php?action=delete+30757
http://master.php.net/manage/user-notes.php?action=reject+30757