PHP soundex() 函数用法及示例

    PHP String 字符串函数手册

    soundex()函数用于计算字符串的 soundex 键。

语法

string soundex ( string $str )

定义和用法

用于计算字符串的 soundex 键。

soundex 键是 4 字符长的字母数字字符串,表示一个单词的英文发音。

soundex() 函数可用于拼写检查程序。

注意:soundex() 函数为发音相似的单词创建相同的键。

提示: metaphone() 比 soundex() 函数更精确,因为 metaphone() 了解英语发音的基本规则。

返回值

它以字符串形式返回 soundex 键

参数

序号参数与说明
1

string

输入字符串

在线示例

试试下面的实例,计算字符串 nhooo.com 的Soundex 键:

<?php
   //计算字符串 nhooo.com 的Soundex 键。
   $input = "nhooo.com";
   echo soundex($input);
?>
测试看看‹/›

输出结果

N250

PHP String 字符串函数手册