note 40844 deleted from function.uksort by thiago
| From: | thiago@php.net | Date: | Tue, 28 Oct 2008 17:12:44 +0000 |
| Subject: | note 40844 deleted from function.uksort by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145886@lists.php.net to get a copy of this message | ||
Note Submitter: jOn
----
a quick function to point uksort() at, for sorting by key, but ignoring "the" from any
keys that start with it:
<?php
function comp($a,$b)
{
//remove "the" (case-insensitive), and any non-word
// characters from any string(s) that start with "the"
$a = preg_replace('|^the\b\W*|i','',$a);
$b = preg_replace('|^the\b\W*|i','',$b);
if ($a == $b) {
return 0;
}
return ($a > $b) ? 1 : -1;
}
?>