Definition and Usage
Definitions and usage
The strnatcmp () function compares two strings using a "natural" algorithm.
The strnatcmp () function is used to compare strings (case sensitive) with natural algorithms.
In a natural algorithm, the number 2 is less than the number 10. In computer sorting, the less than 2, because the "the" of "is" less than 2.
In the "Natural algorithms", 2:10 small. In the computer sequence, 10:2 is small, because the first number in "10" is "1", which is less than 2.
This function returns:
This function returns the following values:
0-if the two strings are equal
0– if the string is equal
<0-if string1 is less than string2
<0– if string1 is less than string2
>0-if string1 is greater than string2
>0– if string1 is greater than string2
Syntax
Grammar
Copy Code code as follows:
STRNATCMP (STRING1,STRING2)
| parameter Parameters |
Description Description |
| String1 |
Required. Specifies the "a" to compare
Necessary parameters. Specifies the first string object to participate in the comparison |
| string2 |
Required. Specifies the second string to compare
Necessary parameters. Specifies the second string object of a parameter comparison |
Tips and Notes
Pay attention.
Note:the strnatcmp () is case-sensitive.
Note: the STRNATCMP () function is case-sensitive.
--------------------------------------------------------------------------------
Example
Case
Copy Code code as follows:
<?phpecho strnatcmp ("2Hello world!", "10Hello world!"); echo "<br/>"; Echo strnatcmp ("10Hello world!", "2Hello world!");? >
The output of the code above would be:
The above code will output the following result:-1 1