(PHP 5 >= 5.3.2, PHP 7, PHP 8, PECL intl >= 1.0.3)
Collator::getSortKey -- collator_get_sort_key — 取得字串的排序鍵值
物件導向風格
程序式風格
傳回字串的排序鍵。排序鍵可以直接比較,而不必比較字串,但排序鍵是依實作而定,並且可能在不同 ICU 程式庫版本之間有所變更。排序鍵通常僅適用於資料庫或其他函式呼叫成本極高的情況。
傳回字串的排序鍵,失敗時則傳回 false
。
範例 #1 collator_get_sort_key() 範例
<?php
$s1 = 'Hello';
$coll = collator_create('en_US');
$res = collator_get_sort_key($coll, $s1);
echo bin2hex($res);
?>
上述範例將輸出類似以下的內容