The collator_compare() function is an inbuilt function in PHP which is used to compare two Unicode strings according to collation rules.
- Procedural style:
int collator_compare( $coll, $str1, $str2 )
- Object oriented style:
int Collator::compare( $str1, $str2 )
Parameters: This function accepts three parameter as mentioned above and described below:
- $coll: This parameter is used as collator object. It provides the comparison capability with support for appropriate locale-sensitive sort orderings.
- $str1: The first string to compare.
- $str2: The second string to compare.
Return Value: This function returns the comparison result which are given below:
- 1: If str1 is greater than str2.
- 0: If str1 is equal to str2.
- -1: If str1 is less than str2.
- Error: It return False.
Below programs illustrate the collator_compare() function in PHP:
Geeks is greater than geeks
GeeksforGeeks is equal to GeeksforGeeks
This article is attributed to GeeksforGeeks.org