levenshtein

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



        foreach ($strings as $string) {

            $levenshteinDistance = levenshtein($input, $string);



            if ($levenshteinDistance === 0) {

                $closestMatch = $string;
<?php                 continue;

            }

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

        }

        asort($similarPackages);