Monday 29 September 2014

strncmp in PHP

PHP strncmp() function is utilized to compares two string.
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:

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

string2 : Required. Specifies the second string

Tip: The PHP strncmp() function is binary safe and case-sensitive.

Example:

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

0 comments:

Post a Comment