Calculate metaphone keys for "World":
<?phpecho metaphone("World");?>The metaphone() function calculates the metaphone key of a string.
The metaphone key represents the English pronunciation of the string.
The metaphone() function can be used in spell checkers.
Note: The metaphone() function creates identical keys for words that sound similar.
Note: The generated metaphone keys are of variable length.
Tip: The metaphone() function is more precise than the soundex() function because metaphone() understands the basic rules of English pronunciation.
metaphone( string,length )
parameter | describe |
---|---|
string | Required. Specifies the string to check. |
length | Optional. Specifies the maximum length of metaphone keys. |
Return value: | Returns the metaphone key of the string on success, or FALSE on failure. |
---|---|
PHP version: | 4+ |
Use the metaphone() function on two words that sound similar:
<?php$str = "Assistance";$str2 = "Assistants";echo metaphone($str);echo "<br>";echo metaphone($str2);?>Use the length parameter:
<?php$str = "Assistance";$str2 = "Assistants";echo metaphone($str,5);echo "<br>";echo metaphone($str2,5);?>