Monday, 29 September 2014

strcasecmp in PHP

 PHP strcasecmp() function is identical to strcmp() function, except that lowercase and uppercase Versions of the same letter compare as equal.
strcasecmp() function returns :

0 – if the two strings are exactly equivalent.
<0 – if smaller byte is found in the string1.
>0 – if smaller byte is found in the string2.
Syntax:

strcasecmp(string1,string2)
string1 : Required. Specifies the first string

string2 : Required. Specifies the second string

Tip : The PHP strcasecmp() function is binary safe and case-insensitive.

Example:

<?php
echo strcasecmp("good morning","Good Morning");
?>
Output will be:
0

0 comments:

Post a Comment