PHP strcasecmp() Function

Definition

This is a case-insensitive version of the strcmp().

Syntax

PHP strcasecmp() Function has the following syntax.

int strcasecmp ( string str1, string str2 )

Parameter

str1 and str2 are the two string values we will compare.

Return

PHP strcmp() Function returns

  • -1 if word one comes alphabetically before word two,
  • 1 if word one comes alphabetically after word two, or
  • 0 if word one and word two are the same.

Example

case-insensitive string value compare


<?PHP
$result = strcasecmp("Hello", "hello"); 
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions