soundex Calculate the soundex key of a string

发表日期:2021-07-01 10:23:23 | 来源: | | 浏览(907) 分类:字符串 函数

soundex

(PHP 4, PHP 5, PHP 7, PHP 8)

soundexCalculate the soundex key of a string

说明

soundex(string $string): string

Calculates the soundex key of string.

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 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.

参数

string

The input string.

返回值

Returns the soundex key as a string with four characters. If at least one letter is contained in string, the returned string starts with a letter. Otherwise "0000" is returned.

更新日志

版本 说明
8.0.0 Prior to this version, calling the function with an empty string returned false for no particular reason.

范例

示例 #1 Soundex Examples

<?php 
soundex("Euler")       == soundex("Ellery");
    // E460soundex("Gauss")       == soundex("Ghosh");
     // G200soundex("Hilbert")     == soundex("Heilbronn");
 // H416soundex("Knuth")       == soundex("Kant");
      // K530soundex("Lloyd")       == soundex("Ladd");
      // L300soundex("Lukasiewicz") == soundex("Lissajous");
 // L222?>

参见

集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。