Latest web development tutorials

PHP metaphone () function

PHP String Reference PHP String Reference

Examples

Calculation "World" of metaphone key:

<?php
echo metaphone("World");
?>

Running instance »

Definition and Usage

metaphone () function calculates the string metaphone key.

metaphone key string representing the pronunciation of English.

metaphone () function can be used a spell checker.

Note: metaphone () function is similar to the pronunciation of the word creates the same key.

Note: The generated metaphone key variable in length.

Tip: metaphone () over () soundex function more accurate, because metaphone () to understand the basic rules of English pronunciation.


grammar

metaphone( string,length )

参数 描述
string 必需。规定要检查的字符串。
length 可选。规定 metaphone 键的最大长度。

technical details

return value: If successful metaphone key string is returned if it fails it returns FALSE.
PHP version: 4+


More examples

Example 1

Two similar sounding words using metaphone () function:

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

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

Running instance »

Example 2

Use length parameters:

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

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

Running instance »


PHP String Reference PHP String Reference