soundex
Calculate the soundex key of a string
soundex()
function calculates the soundex key of a string.
The soundex key is a 4-character alphanumeric string that represents the English pronunciation of the word.
soundex()
function can be used in spellchecking applications.
Note: soundex()
function creates the same key for words with similar pronunciation.
Tip: metaphone()
is more accurate than soundex()
function, because metaphone()
understands the basic rules of English pronunciation.
Calculate the soundex key of "Hello":
<?php $str = "Shanghai" ; echo soundex ( $str ) ; ?>
Try it yourself
Use the soundex() function for two words with similar pronunciation:
<?php $str = "Assistance" ; $str2 = "Assistants" ; echo soundex ( $str ) ; echo "<br>" ; echo soundex ( $str2 ) ; ?>
Try it yourself
soundex ( string )
parameter | describe |
---|---|
string | Required. Specifies the string to be checked. |