Re: case insensitive sort

From: Date: Tue, 26 Aug 2003 15:46:35 +0000
Subject: Re: case insensitive sort
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-160791@lists.php.net to get a copy of this message
It right there under your nose: strcasecmp() Steve Buehler wrote:
I am using the following function for a sort on an array. I hope someone can help me out here and let me know how to change it to make it a "case insensitivie" sort. Right now, it is "case sensitive" so the sort of the array will put the Capital letters first. Here are the results of the search: Buehler, Steve Buehler, Steve Teste, Teste a, a asdf, adsf asdf, asdf dsdlkj, sd Here is the code to sort: $GLOBALS[sortterm]="cont_name"; usort($logins, "cmp"); function cmp ($a, $b) { GLOBAL $sortterm;
    return strcmp($a[$sortterm], $b[$sortterm]);
} Thanks Steve


« previous php.general (#160791) next »