This question already has an answer here:
I have an if
statement in my website. And what I want, is that he won't make distinction in capital letters. My if
statement:
<?php
$nameOne = "JOHN";
$check = "john";
if($nameOne == $check){
echo 'No distinction';
} else {
echo 'distinction ';
}
?>
So, I want to echo
'No distinction'.
</div>
You can use the solution suggested by @NicoHaase
<?php
$var1 = "Hello";
$var2 = "hello";
if (strcasecmp($var1, $var2) == 0) {
echo '$var1 is equal to $var2 in a case-insensitive string comparison';
}
?>
You can make the comparison using strtolower()
on both strings
if (strtolower($nameOne) == strtolower($check))