note 40844 added to function.uksort

From: Date: Tue, 16 Mar 2004 22:57:08 +0000
Subject: note 40844 added to function.uksort
Groups: php.notes 
Request: Send a blank email to php-notes+get-66929@lists.php.net to get a copy of this message
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; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.uksort.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40844 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40844&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40844&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66929) next »