Php/docs/function.soundex
soundex
(PHP 4, PHP 5, PHP 7)
soundex — Calculate the soundex key of a string
Description
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 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.
Parameters
string
- The input string.
Return Values
Returns the soundex key as a string.
Changelog
Version | Description |
---|---|
8.0.0 | Prior to this version, calling the function with an empty string returned FALSE
for no particular reason. |
Examples
Example #1 Soundex Examples
<?phpsoundex("Euler") == soundex("Ellery"); // E460soundex("Gauss") == soundex("Ghosh"); // G200soundex("Hilbert") == soundex("Heilbronn"); // H416soundex("Knuth") == soundex("Kant"); // K530soundex("Lloyd") == soundex("Ladd"); // L300soundex("Lukasiewicz") == soundex("Lissajous"); // L222?>
See Also
- levenshtein() - Calculate Levenshtein distance between two strings
- metaphone() - Calculate the metaphone key of a string
- similar_text() - Calculate the similarity between two strings