Definition and Usage
Definition and usage
The strnatcmp () function compares the strings using a "natural" algorithm.
The strnatcmp () function works by comparing strings (case sensitive) with natural algorithms.
In a natural algorithm, the number 2 was less than the number 10. In computer sorting, than 2, because the first number in "Ten" is less than 2.
In the "Natural algorithms", 2:10 is 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 will return the following values:
0-if the strings is equal
0– if the strings are 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 CodeThe code is as follows:
STRNATCMP (STRING1,STRING2)
| parameter Parameters |
Description Description |
| String1 |
Required. Specifies the first string to compare Necessary parameters. Specifies the first string object to participate in the comparison |
| string2 |
Required. Specifies the second string to compare Necessary parameters. A second string object that specifies a parameter comparison |
Tips and Notes
Watch out.
Note:the strnatcmp () is case-sensitive.
Note: the STRNATCMP () function is case-sensitive.
--------------------------------------------------------------------------------
Example
Case
Copy the Code code as follows:
"; Echo strnatcmp (" 10Hello world! "," 2Hello world! "); >
The output of the code above would be:
The above code will output the following result:-1 1
http://www.bkjia.com/PHPjc/621719.html www.bkjia.com true http://www.bkjia.com/PHPjc/621719.html techarticle definition and usage definitions and usages the strnatcmp () function compares the strings using a "natural" algorithm. STRNATCMP () function is: Compare strings (...) with natural algorithms .