strcmp() function performs a case-sensitive comparison of two strings. : strcmp « String « PHP






strcmp() function performs a case-sensitive comparison of two strings.

 
Its syntax follows: int strcmp (string string1, string string2)

strcmp() returns one of three possible values:

0 if string1 and string2 are equal
< 0 if string1 is less than string2
> 0 if string2 is less than string1

<?
$string1 = "butter";
$string2 = "butter";

if ((strcmp($string1, $string2)) == 0) :
     print "Strings are equivalent!";
endif;
?>
  
  








Related examples in the same category

1.Comparing Strings
2.Comparing strings with strcmp()
3.int strcmp ( string str1, string str2 ), case-insensitive sibling, strcasecmp( )
4.For example, using my collation rules (Canadian-English), I obtain the following results: