导航首页 » 技术教程 » PHP字符串函数soundex()的用法
PHP字符串函数soundex()的用法 142 2023-12-12   

soundex

(PHP 4, PHP 5)

soundex — Calculate the soundex key of a string

说明

string soundex ( string $str )

Calculates the soundex key of str.

Soundex keys have the property that words pronounced similarly produce the same soundex key, and can thus be used to simplify searches in databases where you know the pronunciation but not the spelling. This soundex function returns a string 4 characters long, starting with a letter.

This particular soundex function is one described by Donald Knuth in "The Art Of Computer Programming, vol. 3: Sorting And Searching", Addison-Wesley (1973), pp. 391-392.

参数

str

The input string.

返回值

Returns the soundex key as a string.

范例

Example #1 Soundex Examples

<?php
soundex("Euler")       == soundex("Ellery");    // E460
soundex("Gauss")       == soundex("Ghosh");     // G200
soundex("Hilbert")     == soundex("Heilbronn"); // H416
soundex("Knuth")       == soundex("Kant");      // K530
soundex("Lloyd")       == soundex("Ladd");      // L300
soundex("Lukasiewicz") == soundex("Lissajous"); // L222
?>

参见

levenshtein() - 计算两个字符串之间的编辑距离 metaphone() - Calculate the metaphone key of a string similar_text() - 计算两个字符串的相似度


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103