PHP soundex()Functions

PHP String 参考手册PHP String Reference Manual

Examples

Calculate the soundex key of "Hello":

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

Run example »

Definition and Usage

The soundex() function calculates the soundex key of a 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-checking programs.

Note:The soundex() function creates the same key for words that sound similar.

Tip: metaphone()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 be checked.

Technical Details

Return Value: Returns the soundex key of the string on success, or FALSE on failure.
PHP Version: 4+


More Examples

Example 1

Use the soundex() function on two words that sound similar:

<?php
$str = "Assistance";
$str2 = "Assistants";

echo soundex($str);
echo "<br>";
echo soundex($str2);
?>

Run example »


PHP String 参考手册PHP String Reference Manual Other Extensions