what is the syntax of the STRNCMP() function in php?
strncmp(string1,string2,length)
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to compare |
string2 | Required. Specifies the second string to compare |
length | Required. Specify the number of characters from each string to be used in the comparison |
examples of the STRNCMP() function
Example 1. In this example, we compare two strings (case-sensitive).
<?php
echo strncmp("Hello world!","Hello earth!",6);
?>
Example 1. In this example, we compare two strings (case-sensitive = Hello and hELLo will not output the same).
<?php
echo strncmp("Hello","Hello",6);
echo "<br>";
echo strncmp("Hello","hELLo",6);
?>