超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<similar_textsprintf>
Last updated: Fri, 22 Jun 2007

soundex

(PHP 3, PHP 4 , PHP 5)

soundex -- Calculate the soundex key of a string

Description

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.

例子 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
?>

See also levenshtein(), metaphone(), and similar_text().




add a note add a note User Contributed Notes
soundex
cap at capsi dot cx
13-Dec-1999 11:16
soundex() unfortunately is very sensitive about the first character. It is not possible to use it and have Clansy and Klansy return the same value. If you want to do a phonetic search on such names you will still need to write a routine to evaluate C452 as being similar to K452.

<similar_textsprintf>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22