PHP soundex() Function

Example

Calculate the soundex key for "Hello":

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

Run Instances

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 the soundex() function because metaphone() understands the basic rules of English pronunciation.

Syntax

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

Technical Details

Return Value: Returns the soundex key of the string if successful, otherwise returns FALSE.
PHP Version: 4+

More Examples

Example 1

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

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

Run Instances