levenshtein

Supported Versions: PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8
Calculate Levenshtein distance between two strings
levenshtein(¬†¬†¬†¬†string $string1,¬†¬†¬†¬†string $string2,¬†¬†¬†¬†int $insertion_cost 1,¬†¬†¬†¬†int $replacement_cost 1,¬†¬†¬†¬†int $deletion_cost 1): int
        $closestMatch null;



        foreach (
$strings as $string) {

            
$levenshteinDistance levenshtein($input$string);



            if (
$levenshteinDistance === 0) {

                
$closestMatch $string;
                continue;

            }

            
$similarPackages[$result['name']] = levenshtein($package$result['name']);

        }

        
asort($similarPackages);