Example
Calculate the soundex key of "Hello":
<?php $str = "Hello"; echo soundex($str); ?>
Definition and usage
soundex() function calculates the soundex key of string .
The soundex key is a 4-character long alphanumeric string that represents the English pronunciation of a word.
The soundex() function can be used in spell checkers.
Note: The soundex() function creates the same key for words that sound similar.
Tip: metaphone() is more precise than the soundex() function because metaphone() understands the basic rules of English pronunciation.
Syntax
soundex(string)
Parameters | Description |
string | Required. Specifies the string to check. |
Technical details
Return value: | Returns the soundex key of the string if successful , and returns FALSE if it fails. |
PHP version: | 4+ |
<?php $str = "Assistance"; $str2 = "Assistants"; echo soundex($str); echo "<br>"; echo soundex($str2); ?>
<?php print_r(str_split("Shanghai")); ?>
The above is the detailed content of PHP calculates the soundex key function soundex() of a string. For more information, please follow other related articles on the PHP Chinese website!