Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP metaphone() Function

PHP metaphone() Function

PHP String Reference Manual PHP String Reference Manual

Example

Calculate the metaphone key of "World":

Run Example »


Definition and Usage

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

The metaphone key represents the English pronunciation of a string.

The metaphone() function can be used in spell-checking programs.

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

**Note:** The generated metaphone key has a variable length.

**Tip:** metaphone() is more accurate than soundex() the function, because metaphone() understands the basic rules of English pronunciation.


Syntax

metaphone(

string,length

)

Parameters Description
string Required. Specifies the string to check.
length Optional. Specifies the maximum length of the metaphone key.

Technical Details

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

More examples

Example 1

Use the metaphone() function on two words with similar pronunciation:

"; echo metaphone($str2); ?>

Run Example »

Example 2

Use the length parameter:

"; echo metaphone($str2,5); ?>

Run Example »


PHP String Reference Manual PHP String Reference Manual