note 21617 deleted from function.sort by derick
| From: | derick@php.net | Date: | Wed, 31 Aug 2005 10:38:29 +0000 |
| Subject: | note 21617 deleted from function.sort by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-94496@lists.php.net to get a copy of this message | ||
Note Submitter: oatmealrox AMPERSAND hotmail PERIOD com
----
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.