PHP strncmp() function is utilized to compares two strings.
The 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:
strncmp(string1,string2,length)
string1 : Required. Specifies the first string.
string2 : Required. Specifies the second string.
length : Required. Specify the number of characters to use in the comparison.
Tip : This function is binary safe and case-sensitive.
Example:
<?php
echo strncmp("Good Morning","Good night",5);
?>
Output will be:
0
The 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:
strncmp(string1,string2,length)
string1 : Required. Specifies the first string.
string2 : Required. Specifies the second string.
length : Required. Specify the number of characters to use in the comparison.
Tip : This function is binary safe and case-sensitive.
Example:
<?php
echo strncmp("Good Morning","Good night",5);
?>
Output will be:
0
0 comments:
Post a Comment