String Similarity

Calculate the similarity percentage between two strings based on edit distance.

Code

Algorithms
$distance = levenshtein($a, $b);
$maxLen = max(strlen($a), strlen($b));
return round((1 - $distance / $maxLen) * 100);

Parameters

First string

Second string

Server

More PHP Snippets