The strnatcasecmp() function is used compare two strings with a natural algorithm.
Note − The function is case sensitive.
Syntax
strnatcasecmp(str1, str2)
Parameters
str1 − First string to compare
str2 − Second string to compare
Return
The strcoll() function returns −
0 − if the two strings are equal
< 0 − if string1 is less than string2
> 0 − if string1 is greater than string2
Example
The following is an example −
<?php
echo strnatcasecmp("Demo", "DEMO");
?>
Output
0
Example
The following is an example −
<?php
echo strnatcasecmp("5Demo", "50DEMO");
echo "\n";
echo strnatcasecmp("50Demo", "5DEMO");
echo "\n";
echo strnatcasecmp("100Demo", "100Demo");
?>
Output
-1 1 0