本文整理匯總了PHP中CString::metaphoneKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP CString::metaphoneKey方法的具體用法?PHP CString::metaphoneKey怎麽用?PHP CString::metaphoneKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CString
的用法示例。
在下文中一共展示了CString::metaphoneKey方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: metaphoneKey
/**
* Returns the Metaphone key "heard" from a string.
*
* The algorithm used to render the [Metaphone](http://en.wikipedia.org/wiki/Metaphone) key is the first-generation
* one.
*
* @param string $string The source string.
* @param bool $transliterate **OPTIONAL. Default is** `true`. Tells whether to transliterate the string into the
* Latin script and then flatten it to ASCII before generating the key. Since the Metaphone algorithm is not
* Unicode-aware, the touch of transliteration is something that any arbitrary Unicode string would wish for. For
* example, "こんにちは" is transliterated to "kon'nichiha".
*
* @return string The Metaphone key of the string.
*/
public static function metaphoneKey($string, $transliterate = true)
{
assert('is_cstring($string) && is_bool($transliterate)', vs(isset($this), get_defined_vars()));
$string = CEString::flattenUnicodeToAscii($string, $transliterate);
return CString::metaphoneKey($string);
}