PHP soundex() Function

Example

Calculate the soundex key of "Hello":

<?php
$str = "Shanghai";
echo soundex($str);
?>

Run Instance

Definition and Usage

The soundex() function calculates the soundex key of the string.

The soundex key is a 4-character alphanumeric string that represents the English pronunciation of the word.

The soundex() function can be used in spelling check applications.

Note:The soundex() function creates the same key for words with similar pronunciation.

Tip:metaphone() More accurate than soundex() function because metaphone() understands the basic pronunciation rules of English.

Syntax

soundex(string)
Parameter Description
string Required. Specifies the string to be checked.

Technical Details

Return Value: If successful, it returns the soundex key of the string, if failed, it returns FALSE.
PHP Version: 4+

More Examples

Example 1

Use soundex() function for two words with similar pronunciation:

<?php
$str = "Assistance";
$str2 = "Assistants";
echo soundex($str);
echo "<br>";
echo soundex($str2);
?>

Run Instance