PHP metaphone() function

PHP metaphone() function is predefined function. It is used to calculate the metaphone key of a string. It is useful to text search and text matching application.

It is phonetic algorithm developed by Lawrence Philips. The algorithm produces variable length keys as output.

Syntax:

ParameterDescriptionRequired/Optional
StringSpecify input string.Required
LengthSpecify the max length of the megaphones key.Optional

Example 1

Output:

Before using metaphone() function:Hello PHP
After using metaphone() function: HLFP

Example 2

Output:

NS
NS

Example 3

Output:

string(7) "PRKRMNK" 
string(6) "PRKRMR"

Example 4

Output:

NS
NS

Note: Given above example by using the length of parameter.


Next TopicPHP String




Latest Courses