Reputation: 4601
Is there an operator in PHP that allows incasesensitive comparisons?
Instead of doing the following:
if (strtolower("A") == strtolower("a") )
I guess I'm looking for something like:
if ^("A" == "a")
Where ^
tells php to ignore the case based comparison.
Yes, I do have a wild imagination. :)
Upvotes: 0
Views: 899
Reputation: 265201
You can use stricmp
if(!strcasecmp('a', 'A')) echo 'strings are equal';
Upvotes: 3
Reputation: 95101
You can use http://www.php.net/manual/en/function.strcasecmp.php strcasecmp
if (strcasecmp("A", "a") == 0) {
echo 'OK';
}
Thanks
:)
Upvotes: 1
Reputation: 7924
You can use strcasecmp
for this. Just check that it returns 0.
if (strcasecmp("A", "a") == 0) {
// yes
}
Upvotes: 1