Compare two strings (case insensitive):
<?phpecho strncasecmp("Hello world!","hello earth!",6);?>The strncasecmp() function compares two strings (case-insensitive).
Note: strncasecmp() is binary-safe and case-insensitive.
Tip: This function is similar to the strcasecmp() function, except that strcasecmp() does not have a length parameter.
strncasecmp( string1,string2,length )
parameter | describe |
---|---|
string1 | Required. Specifies the first string to compare. |
string2 | Required. Specifies the second string to be compared. |
length | Required. Specifies the number of characters per string used for comparison. |
Return value: | The function returns: 0 - if the two strings are equal <0 - if string1 is less than string2 >0 - if string1 is greater than string2 |
---|---|
PHP version: | 4.0.2+ |
Compare two strings (not case sensitive, Hello and hELLo output the same):
<?phpecho strncasecmp("Hello","Hello",6);echo "<br>";echo strncasecmp("Hello","hELLo",6);?>