PHP levenshtein() Function

The levenshtein() function in PHP calculates the Levenshtein distance between two strings.

Syntax

Parameter

str1(required)- This parameter signifies one of the strings being evaluated for Levenshtein distance.

str2(required)- This parameter signifies one of the strings being evaluated for Levenshtein distance.

cost_ins(optional)– This parameter specifies the cost insertion.

cost_rep(optional)- This parameter specifies the cost of replacement.

cost_del(optional)- This parameter specifies the cost of deletion.

Return

This function returns the Levenshtein-Distance between the two specified strings or returns -1, if one of the argument strings is longer than the limit of 255 characters.

Example 1

Output

Example 2

Output

Example 3

Output

Pin It on Pinterest

Share This