The metaphone() function is used to calculate the metaphone key of a string. This is a key that represent how a string sounds if spoken by someone who speaks in English.
Syntax
metaphone(str, len)
Parameters
str − The string to check.
len − The maximum length of the metaphone key.
Return
The metaphone() function returns the metaphone key of the string on success, or FALSE on failure.
Example
The following is an example −
<?php var_dump(metaphone('demo')); ?>
Output
The following is the output −
string(2) "TM"
Example
Let us see another example −
<?php var_dump(metaphone('Welcome', 3)); ?>
Output
The following is the output −
string(3) "WLK"
Example
Let us now see another example of the words that look similar −
<?php $one = "Since"; $two = "Sins"; echo metaphone($one); echo "<b>"; echo metaphone($two); ?>
Output
The following is the output −
SNS SNS