Page 1 of 1

case insensitive string comparison

Posted: Tue Jun 15, 2004 7:01 am
by davidklonski
Hello

I need to compare string in a locale-aware manner.
I was using strcoll.

However, I need a case insensitive string comparison.
Does anyone know of a way to achieve that?
I cannot use strcasecmp because it is not locale-aware.

thanks in advance.

Posted: Tue Jun 15, 2004 7:28 am
by Grim...
Convert both strings to lowercase first using [php_man]strtolower[/php_man]?

Posted: Tue Jun 15, 2004 8:26 am
by Joe

Code: Select all

$string1 = "HELLO";
$string2 = "hello";

$string1 = strtolower($string1);

if ($string1 == $string2)
 True;
else
 False;

Posted: Tue Jun 15, 2004 8:27 am
by Joe
^_^ Just a little example, hehe

Posted: Tue Jun 15, 2004 8:28 am
by Bill H
Or strcasecmp(str1, str2);