note 35720 added to function.natcasesort
| From: | vbAlexDOSMan at Yahoo dot com | Date: | Fri, 12 Sep 2003 05:21:57 +0000 |
| Subject: | note 35720 added to function.natcasesort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56288@lists.php.net to get a copy of this message | ||
Ulli at Stemmeler dot net: I remade your function -- it's a little more compact now --
Enjoy...
function ignorecasesort(&$array) {
/*Make each element it's lowercase self plus itself*/
/*(e.g. "MyWebSite" would become "mywebsiteMyWebSite"*/
for ($i = 0; $i < sizeof($array); $array[$i] = strtolower($array[$i]).$array[$i], $i++);
/*Sort it -- only the lowercase versions will be used*/
sort($array);
/*Take each array element, cut it in half, and add the latter half to a new array*/
/*(e.g. "mywebsiteMyWebSite" would become "MyWebSite")*/
for ($i = 0; $i < sizeof($array); $i++) {
$this = $array[$i];
$array[$i] = substr($this, (strlen($this)/2), strlen($this));
}
}
----
Manual Page -- http://www.php.net/manual/en/function.natcasesort.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35720
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35720&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35720&report=yes