Search code examples
phpcomparecomparisonmetaphone

How to compage 2 metaphone results


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 ?


Solution

  • I tried this :

    <?php
    
    $metaphone1 = "OSKRSWRNNTFYFFTFRHNNSSBSTPKTR";
    $metaphone2 = "FYNTTNWSWRNBTRPRTTLRKTFRHKTTRT0BSTPKTRWNRT0SKR";
    $metaphone3 = "WERTYTRSDVVQQOSKRSWRNNTFYFFTFRHNNSSBSTPKTR";
    
    echo levenshtein($metaphone1,$metaphone2); // Returns 30
    echo levenshtein($metaphone2,$metaphone3); // Returns 36
    
    
    ?>