int strcmp ( string str1, string str2 ), case-insensitive sibling, strcasecmp( ) : strcmp « String « PHP






int strcmp ( string str1, string str2 ), case-insensitive sibling, strcasecmp( )

 
<?
    $string1 = "foo";
    $string2 = "bar";
    $result = strcmp($string1, $string2);

    switch ($result) {
            case -1: print "Foo comes before bar"; break;
            case 0: print "Foo and bar are the same"; break;
            case 1: print "Foo comes after bar"; break;
    }
?>
  
  








Related examples in the same category

1.Comparing Strings
2.Comparing strings with strcmp()
3.strcmp() function performs a case-sensitive comparison of two strings.
4.For example, using my collation rules (Canadian-English), I obtain the following results: