strncasecmp
Binary safe comparison of several characters at the beginning of a string (case insensitive)
strncasecmp() function compares two strings.
Note: strncasecmp() is binary-safe and is not case sensitive.
Tip: This function is similar to strcasecmp() function. The difference is that strcasecmp() does not have a length parameter.
Compare two strings (case insensitive):
<?php echo strncasecmp ( "I love China!" , "I love Shanghai!" , 6 ) ; ?>
Try it yourself
Compare two strings (case insensitive, China and CHINA output the same):
<?php echo strncasecmp ( "China" , "China" , 6 ) ; echo "<br>" ; echo strncasecmp ( "China" , "CHINA" , 6 ) ; ?>
Try it yourself
strncasecmp ( string1 , string2 , length )
| parameter | describe |
|---|---|
| string1 | Required. Specifies the first string to be compared. |
| string2 | Required. Specifies the second string to be compared. |
| length | Required. Specifies the number of characters each string uses for comparison. |