PHP soundex() Function

Definition

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

Syntax

PHP soundex() Function has the following syntax.

soundex(string)

Parameter

ParameterIs RequiredDescription
stringRequired. String to check

Note

A soundex key is a four character long alphanumeric string that represent English pronunciation of a word.

The soundex() function creates the same key for similar sounding words.

metaphone() is more accurate than soundex(), because metaphone() knows the basic rules of English pronunciation.

Return

PHP soundex() Function returns the soundex key of the string on success, or FALSE on failure.

Example

Calculate the soundex key of "Hello":


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

The code above generates the following result.

Example 2

Using the soundex() function on two similar sounding words:


<?php/* w  w w .ja v  a  2 s . co  m*/
$str = "phone";
$str2 = "fone";

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

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions