Syntax:public Collator::__ construct (string $locale)
Parameters: This function takes one parameter,
$locale,which contains the sorting rules. If null is passed for a locale, the default locale matching rules will be used. If an empty string ("") or "root" is passed in the locale, then UCA rules will be used.
Return value:This function returns a Collator instance.The following programs illustrate the Collator::__ construct() function in PHP:
Program 1: $coll
=
new
Collator (
’en_CA’
);
var_dump (
$coll
);
?>
Exit:object (Collator ) # 1 (0) {}
Program 2: $coll
=
new
Collator (
’en_CA’
);
// Declare an array and initialize it
$arr
=
array
(
’ geek’
,
’geeK’
,
’Geek’
,
’ engineer’
);
// Sort array
collator_sort (
$coll
,
$arr
);
// Show array contents
var_export (
$arr
);
?>
Exit:array (0 = > ’geek’, 1 = >’ geeK’, 2 = > ’Geek’, 3 = >’ engineer’,)
Link: https://www.php.net/manual/en/collator.construct.php