Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP strncasecmp() Function

PHP strncasecmp() Function

PHP String Reference Manual PHP String Reference Manual

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:** The difference between this function and strcasecmp() The strncasecmp() function is similar, except that strcasecmp() has no length parameter.


Syntax

strncasecmp(

string1,string2,length

)

Parameters Description
string1 Required. Specifies the first string to compare.
string2 Required. Specifies the second string to compare.
length Required. Specifies the number of characters of each string to compare.

Technical Details

| Return value: | This function returns:

| | --- | --- | | PHP version: | 4.0.2+ |

More examples

Example 1

Compare two strings (case-insensitive, Hello and hELLo produce the same output):

"; echo strncasecmp("Hello","hELLo",6); ?>

Run Example »


PHP String Reference Manual PHP String Reference Manual