A method that ignores case when comparing two strings.
There will often be times that you will need to compare two strings by ignoring the case of the string. There are many ways to accomplish this in programming more often than not by converting both strings to lower or upper case characters. Some languages have built in ways of doing this, others will require a few extra steps.
For example, in Java the String class contains a method called equalsIgnoreCase. The Java 7 API description for equalsIgnoreCase:
Compares this String to another String, ignoring case considerations.
An example of how to use equalsIgnoreCase in Java that will return false:
String x = "Hello";
String y = "World";
if(x.equalsIgnoreCase(y)) {
return true;
} else {
return false;
}
To accomplish the same thing in PHP you could do the following:
<?php
$var1 = "Hello";
$var2 = "hello";
if (strcasecmp($var1, $var2) == 0) {
echo '$var1 is equal to $var2 in a case-insensitive string comparison';
}
?>
The above example was taken from the PHP documentation.