PHP function strcoll() that compares two strings (according to local settings)

黄舟
Release: 2023-03-17 06:20:02
Original
1152 people have browsed it

Example

ComparisonString:

"; setlocale (LC_COLLATE, 'en_US'); echo strcoll("Hello World!","Hello World!"); ?>
Copy after login

Definition and usage

strcoll() function compares two strings.

The comparison of strings changes depending on the local setting (Aa).

Note: strcoll() is case-sensitive, but not binarysafe.

Note: If the current locale is C or POSIX, this function works the same asstrcmp().

Syntax

strcoll(string1,string2)
Copy after login
Parameters Description
string1 Required. Specifies the first string to compare.
string2 Required. Specifies the second string to be compared.

Technical details

##PHP version: Update Log Example
Return value: This function returns:
  • 0 - if the two strings are equal

  • ##<0 - if string1 is less than string2

  • >0 - if string1 Greater than string2

4.0.5+
:Since PHP 4.2.3, this function can work on win32.
"; setlocale (LC_COLLATE, 'en_US'); echo strcoll("Hello World!","Hello WORLD!"); ?>
Copy after login

Output:

-1 1
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!