توابع metaphone در PHP

مثال

محاسبه کلید metaphone برای "World":

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

Run Instance

Definition and Usage

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

The metaphone key represents the English pronunciation of the string.

The metaphone() function can be used in spelling check programs.

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

Note:The length of the generated metaphone key can vary.

Tip:metaphone() is compared to soundex() The function is more accurate because metaphone() understands the basic rules of English pronunciation.

Syntax

metaphone(string,length)
Parameter Description
string Required. Specify the string to be checked.
length Optional. Specify the maximum length of the metaphone key.

Technical Details

Return Value: Returns the metaphone key of the string if successful, or FALSE if failed.
PHP Version: 4+

More Examples

Example 1

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

<?php
$str = "Assistance";
$str2 = "Assistants";
echo metaphone($str);
echo "<br>";
echo metaphone($str2);
?>

Run Instance

Example 2

Usage length Parameters:

<?php
$str = "Assistance";
$str2 = "Assistants";
echo metaphone($str,5);
echo "<br>";
echo metaphone($str2,5);
?>

Run Instance