PHP strnatcasecmp() Function


The strnatcasecmp() function is used to compare two strings using a "natural" algorithm.

Syntax
strnatcasecmp(string1,string2)
Parameters
  • String - (Required) Specify the First string to compare.
  • String - (Required) Specify the second string to compare.
Example
<?php
    echo strnatcasecmp("20Good Morning!","10Good Morning!");
    echo "<br>";
    echo strnatcasecmp("10Good Morning!","20Good Morning!");
?>

Output

1
-1

Prev Next