PHP soundex() 函式
定義和用法
soundex() 函式計算字串的 soundex 鍵。
Soundex 鍵是一個四字元的字母數字字串,代表一個單詞的英語發音。
soundex() 函式可用於拼寫應用程式。
注意: soundex() 函式會為發音相似的單詞生成相同的鍵。
提示: metaphone() 比 soundex() 更準確,因為 metaphone() 瞭解英語發音的基本規則。
語法
soundex(string)
引數值
引數 | 描述 |
---|---|
string | 必需。指定要檢查的字串 |
技術詳情
返回值 | 成功時返回字串的 soundex 鍵,失敗時返回 FALSE。 |
---|---|
PHP 版本 | 4+ |
更多示例
示例
對兩個發音相似的單詞使用 soundex() 函式
<?php
$str = "Assistance";
$str2 = "Assistants";
echo soundex($str);
echo "<br>";
echo soundex($str2);
?>
自己動手試一試 »
❮ PHP 字串參考