1

I'm wondering if there is an efficient way to compare 2 metaphone results in php.

metaphone 1 = OSKRSWRNNTFYFFTFRHNNSSBSTPKTR

metaphone 2 = FYNTTNWSWRNBTRPRTTLRKTFRHKTTRT0BSTPKTRWNRT0SKR

What would a good start or approach ?

  • 1
    Take a look at the php [`levenshtein()` function](http://php.net/manual/en/function.levenshtein.php) – JazZ Mar 04 '17 at 21:16
  • Thanks, at first I wasn't sure it could help me. I gave it a try see my answer –  Mar 04 '17 at 21:38

1 Answers1

1

I tried this :

<?php

$metaphone1 = "OSKRSWRNNTFYFFTFRHNNSSBSTPKTR";
$metaphone2 = "FYNTTNWSWRNBTRPRTTLRKTFRHKTTRT0BSTPKTRWNRT0SKR";
$metaphone3 = "WERTYTRSDVVQQOSKRSWRNNTFYFFTFRHNNSSBSTPKTR";

echo levenshtein($metaphone1,$metaphone2); // Returns 30
echo levenshtein($metaphone2,$metaphone3); // Returns 36


?>