PHP strcasecmp() Function
In this chapter you will learn:
- Definition for PHP strcasecmp() Function
- Syntax for PHP strcasecmp() Function
- Parameter for PHP strcasecmp() Function
- Return for PHP strcasecmp() Function
- Example - case-insensitive string value compare
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");
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP strchr() Function
- Syntax for PHP strchr() Function
- Parameter for PHP strchr() Function
- Return for PHP strchr() Function
- Example - Find the first occurrence of "world" inside "Hello world!" and return the rest of the string
- Example - Search a string for the ASCII value of "o" and return the rest of the string
- Example - Return the part of the string before the first occurence of "world"
Home » PHP Tutorial » PHP String Functions