[PHP] case insensitive sort

2003-08-26 Thread Steve Buehler
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] case insensitive sort

2003-08-26 Thread Steve Buehler
Ok.  Now I REALLY feel like an idiot.  Thanks so much for your help.

Steve

At 05:46 PM 8/26/2003 +0200, you wrote:
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


--
This message has been scanned for viruses and
dangerous content by the MailScanner at ow4, and is
believed to be clean.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] case insensitive sort

2003-08-26 Thread Marek Kilimajer
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php