Syntax: Parameters:This function takes one parameter,
$locale,which contains the required matching 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 new instance of the sorter object on success or NULL in case of error.The following programs illustrate the Collator::create() function in PHP:
Program 1: $coll
= collator_create (
’en_US’
);
if
(isset (
$coll
)) {
echo
" Collector created "
;
}
else
{
echo
" Collector not created "
;
}
?>
Exit:Collector created
Program 2: $coll
= collator_create (
’en_US’
);
// 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.create.php