<?php
$str1 = "red";
$str2 = "redent";
$test=strncasecmp($str1, $str2 , 3);
if ($str1==$str2)
{
echo "$test";
}
else
{
echo "$test" ;
}
?>
if we run the above script then we will get return 0, because first string $str1 = "red" and second $str2 = "redent" but in comparison i have set the first three character will try to match. as per condition if two string are equal then it will return 0. But in below example it will return greater than 0 because here is str1 is greater than str2.
<?php
$str1 = "redmyshirt";
$str2 = "redent";
$test=strncasecmp($str1, $str2 , 4);
if ($str1==$str2)
{
echo "$test";
}
else
{
echo "$test" ;
}
?>
as same if we run the below script it will return -1 because str1 is less than str2.
<?php
$str1 = "red";
$str2 = "redent";
$test=strncasecmp($str1, $str2 , 4);
if ($str1==$str2)
{
echo "$test";
}
else
{
echo "$test" ;
}
?>
ya..i think its easy to understand