The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform $str1 into $str2.

In its simplest form the function will take only the two strings as parameter and will calculate just the number of insert, replace and delete operations needed to transform $str1 into $str2.

A second variant will take three additional parameters that define the cost of insert, replace and delete operations. This is more general and adaptive than variant one, but not as efficient.

declaration of levenshtein

int levenshtein ( string $string1 , string $string2 [, int $cost_ins ] [, int $cost_rep ] [, int $cost_del ] )

test levenshtein online

share levenshtein

comments for levenshtein

be the first

No comments so far for levenshtein(). Leave yours as first below.


Leave your comment