note 39021 added to function.sort

From: Date: Wed, 14 Jan 2004 20:01:05 +0000
Subject: note 39021 added to function.sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-63564@lists.php.net to get a copy of this message
Another very simple way to sort a simpe array as Case INsensitive (maybe it could be made even simpler, but i don't have high PHP knowledge) <?php function SortArray($array_old) { $c=count($array_old); // count elements in a variable for ($i=0; $i<$c; $i++) $array_low[$i]=strtolower($array_old[$i]); // make a new, lower case, array sort ($array_low); // here is a true case insensitive sort for ($i=0; $i<$c; $i++) for ($i2=0; $i2<$c; $i2++) if ($array_low[$i]==strtolower($array_old[$i2])) $array_low[$i2]=$array_old[$i]; // we want to get the old case back return $array_low; } $AnyArray = SortArray($AnyArray); // here is an example of how to use the function ?> ---- Manual Page -- http://www.php.net/manual/en/function.sort.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39021 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39021&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39021&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63564) next »