Home >Backend Development >PHP Tutorial >PHP function strcoll() that compares two strings (according to local settings)
Example
ComparisonString:
<?php setlocale (LC_COLLATE, 'NL'); echo strcoll("Hello World!","Hello World!"); echo "<br>"; setlocale (LC_COLLATE, 'en_US'); echo strcoll("Hello World!","Hello World!"); ?>
Definition and usage
strcoll() function compares two strings.
The comparison of strings changes depending on the local setting (A8866508e6f635ebe7431948a1ce090eda).
Note: strcoll() is case-sensitive, but not binary safe.
Note: If the current locale is C or POSIX, this function works the same as strcmp().
Syntax
strcoll(string1,string2)
Parameters | Description |
string1 | Required. Specifies the first string to compare. |
string2 | Required. Specifies the second string to be compared. |
Technical details
<?php setlocale (LC_COLLATE, 'NL'); echo strcoll("Hello World!","Hello WORLD!"); echo "<br />"; setlocale (LC_COLLATE, 'en_US'); echo strcoll("Hello World!","Hello WORLD!"); ?>
Output:
-1 1
The above is the detailed content of PHP function strcoll() that compares two strings (according to local settings). For more information, please follow other related articles on the PHP Chinese website!