Phpstrnatcasecmp () uses a natural sorting algorithm to compare two strings (case insensitive). This article introduces the usage and examples of phpstrnatcasecmp () functions to coders, for more information, see. Definition and usage
The strnatcasecmp () function uses a "natural" algorithm to compare two strings.
In natural algorithms, number 2 is smaller than Number 10. In computer sorting, 10 is less than 2, because the first number in 10 is less than 2.
Note: strnatcasecmp () is case insensitive.
Syntax
strnatcasecmp(string1,string2)
Parameters |
Description |
String1 |
Required. Specifies the first string to be compared. |
String2 |
Required. Specifies the second string to be compared. |
Return value
Return value: |
This function returns:
- 0-if the two strings are equal
- <0-if string1 is smaller than string2
- > 0-if string1 is greater than string2
|
PHP version: |
4 + |
Instance
"; Echo strnatcasecmp (" 10 Hello world! "," 2 Hello WORLD! ");?>
Online operation