note 30756 added to function.sort

From: Date: Thu, 27 Mar 2003 16:28:16 +0000
Subject: note 30756 added to function.sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-45909@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+30756 http://master.php.net/manage/user-notes.php?action=delete+30756 http://master.php.net/manage/user-notes.php?action=reject+30756

« previous php.notes (#45909) next »