note 21617 added to function.sort

From: Date: Tue, 21 May 2002 14:49:22 +0000
Subject: note 21617 added to function.sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-30834@lists.php.net to get a copy of this message
Here's my simple solution to an array not being sorted alpahbetically when capitals are involved: $strings[0]="blue"; $strings[1]="red"; $strings[2]="green"; #Set the key values of a new array to a lowercase version of each string value. foreach($strings as $one_string){ $array[strtolower($one_string)] = $one_string; } #then sort by the keys... ksort($array); Now the array $array is your original array but in alphabetical order. Of course, you can only use this if the key values don't need to be preserved. -- http://www.php.net/manual/en/function.sort.php http://master.php.net/manage/user-notes.php?action=edit+21617 http://master.php.net/manage/user-notes.php?action=delete+21617 http://master.php.net/manage/user-notes.php?action=reject+21617

« previous php.notes (#30834) next »