129 of 410 menu

The metaphone Function

The metaphone function returns the metaphone of a string - a phonetic key that allows comparing words by their sound. The first parameter is the string to process, and the second (optional) one is the maximum length of the returned metaphone.

Syntax

metaphone(string, [phonemes]);

Example

Let's calculate the metaphone for the word "programming":

<?php echo metaphone('programming'); ?>

Code execution result:

'PRKRMNK'

Example

Let's compare metaphones for words that sound similar:

<?php $res1 = metaphone('write'); $res2 = metaphone('right'); var_dump($res1 === $res2); ?>

Code execution result:

true

Example

Let's limit the metaphone length to 4 characters:

<?php echo metaphone('international', 4); ?>

Code execution result:

'ANTR'

See Also

  • the soundex function,
    which calculates the soundex-key of a string
  • the levenshtein function,
    which calculates the distance between strings
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline