English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP strcoll() Function Usage and Example

PHP String String Function Manual

The strcoll() function compares strings based on the locale.

Syntax

int strcoll(string $str1 , string $str2 )

Definition and Usage

It is used to compare two strings based on the language environment.

Since PHP 4.2.3 starting, this function can be used in win32 is working.

Return Value

 If str1 Less than str2 Returns < 0; if str1 Greater than str2 Returns > 0; if both are equal, returns 0.

Parameter

Serial NumberParameters and Description
1

str1

It specifies the first string to be compared

2

str2

It specifies the second string to be compared

Online Example

Try the following example to compare strings:

<?php
   echo "If this function returns 0, the two strings are equal.";
   echo "<br> The result is ";
   
   setlocale(LC_COLLATE, 'NL');
   echo strcoll("Hello World!", "Hello World!");
?>
Test and see‹/›

Output Result

If this function returns 0, the two strings are equal.
The result is 0

PHP String String Function Manual