PHP strnatcmp() Function


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

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

Output

1
-1

Prev Next