PHP metaphone() Function (original) (raw)

Last Updated : 21 Jun, 2023

The metaphone() function is a built-in function in PHP and is used to calculate the metaphone key of a given string. The Metaphone key is a phonetic algorithm for indexing of words by their pronunciation. It uses the larger set of rules for English pronunciation.

Syntax:

string metaphone ( str,str, str,key )

Parameters: This function accepts two parameters as mentioned above and described below:

Return Value: It returns the metaphone key as a string, and return FALSE in failure. Examples:

Input: $str = "Contribute Article on GeeksforGeeks" Output: KNTRBTRTKLNJKSFRJKS

Input: str="ContributeArticleonGeeksforGeeks"str = "Contribute Article on GeeksforGeeks" str="ContributeArticleonGeeksforGeeks"key = 5 Output: KNTRB

Below programs illustrate the metaphone() function in PHP.

Program 1:

php `

`

Output:

KNTRBTRTKLNJKSFRJKS AKMPTRSNSPRTL

Program 2:

php `

`

Related Article: PHP | soundex() Function

Reference: http://php.net/manual/en/function.metaphone.php