PHP strncasecmp() Function

P
PHP strnatcmp() Function
PHP strncmp() Function

what is the syntax of the STRNCASECMP() function in php?

strncasecmp(string1,string2,length)
ParameterDescription
string1Required. Specifies the first string to compare
string2Required. Specifies the second string to compare
lengthRequired. Specify the number of characters from each string to be used in the comparison
PHP STRNCASECMP() method

examples of the STRNCASECMP() function

Example 1. In this example, we compare two strings (case-insensitive).

<?php
echo strncasecmp("Hello world!","hello earth!",6);
?>

Example 2. In this example, we compare two strings (case-insensitive = Hello and hELLo will output the same).

<?php
echo strncasecmp("Hello","Hello",6);
echo "<br>";
echo strncasecmp("Hello","hELLo",6);
?>
PHP strnatcmp() Function
PHP strncmp() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z