Case insensitive natural comparison of two strings.
This function works just like strnatcmp(), but is case insensitive.
<?php
$s1 = "document10";
$s2 = "document2";
$s3 = "DOCUMENT2";
if (strnatcasecmp($s1, $s2) < 0) {
print "$s1 is smaller than $s2<br>";
} else {
print "$s2 is smaller than $s1<br>";
}
if (strnatcasecmp($s2, $s3) == 0) {
print "$s2 is equal to $s3<br>";
} else {
print "$s2 and $s3 are not equal<br>";
}
?>
document2 is smaller than document10
document2 is equal to DOCUMENT2
The strings are compared in natural order and lower and upper case characters are valued equally.