I have this code:
$a = 'abc';
$b = 'AbC';
if ($a == $b)
{
echo 'abc == ABc!';
}
else
{
echo 'abc != ABc!';
}
Now it echoes abc != ABc!
but i'd like it to match the strings regardless of the capitals.
I have this code:
$a = 'abc';
$b = 'AbC';
if ($a == $b)
{
echo 'abc == ABc!';
}
else
{
echo 'abc != ABc!';
}
Now it echoes abc != ABc!
but i'd like it to match the strings regardless of the capitals.
Two options:
1) convert the casing and do a comparison.
strtolower($a) === strtolower($b)
One caveat of this is that for non-utf8 characters and non-english languages this does not work well.
2) use case insensitive comparison
if (strcasecmp($a, $b) == 0) {