YouTip LogoYouTip

Func String Strncasecmp

# PHP strncasecmp() Function [![Image 3: PHP String Reference](#) PHP String Reference](#) ## Example Compare two strings (case-insensitive): [Run Example Β»](#) * * * ## Definition and Usage 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, with the difference that strcasecmp() does not have a length parameter. * * * ## Syntax strncasecmp(_string1,string2,length_) | Parameter | Description | | --- | --- | | _string1_ | Required. Specifies the first string to compare. | | _string2_ | Required. Specifies the second string to compare. | | _length_ | Required. Specifies the number of characters from each string to use in the comparison. | ## Technical Details | Return Value: | The function returns: * 0 - if the two strings are equal * 0 - if string1 is greater than string2 | | :--- | | PHP Version: | 4.0.2+ | * * * ## More Examples ## Example 1 Compare two strings (case-insensitive, "Hello" and "hELLo" output the same): <?php echo strncasecmp("Hello","Hello",6); echo "
"; echo strncasecmp("Hello","hELLo",6); ?> [Run Example Β»](#) * * PHP String Reference](#)
← Func String StrncmpFunc String Strnatcmp β†’