Home >>PHP String Functions >PHP soundex() Function
PHP soundex() function is used to calculates the soundex key of a given input string. This soundex key is an alphanumeric string of four characters that represent English pronunciation of the given string. This Soundex function was described by Donald Knuth. This function can be used in the spelling applications.
Metaphone() function works more accurately than the soundex() function because methaphone() knows the basic rules of English pronunciation.
Syntax:
soundex($string);
Parameter | Description |
---|---|
string | This is a required parameter. This parameter contains the string to be checked. |
Here is an example of soundex() function in PHP:
<html> <body> <?php $str = "PHPTPOINT"; echo soundex($str); ?> </body> </html>
Here is an another example of soundex() function in PHP:
<html> <body> <?php $str = "Here"; $str2 = "Hear"; echo soundex($str); // For Here echo "<br>"; echo soundex($str2); // For Hear ?> </body> </html>