PHP/String/strcasecmp — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 10:37, 26 мая 2010
Содержание
Comparing strings case-insensitively
<?
if (strcasecmp("a@demo.ru", "a@demo.ru") == 0) {
print "Welcome back, Mr..";
}
?>
int strcasecmp ( string str1, string str2 ) is a case-insensitive version of the strcmp( ) .
<?
$result = strcasecmp("Hello", "hello");
?>
strcasecmp() function operates like strcmp(), except that its comparison is case insensitive.
Its syntax is: int strcasecmp (string string1, string string2)
<?
$string1 = "butter";
$string2 = "Butter";
if ((strcasecmp($string1, $string2)) == 0) :
print "Strings are equivalent!";
endif;
?>
Using strcasecmp to compare two strings
<?php
$name1 = "Bill";
$name2 = "BILL";
$result = strcasecmp($name1, $name2);
if (!$result){
echo "They match.";
}
?>