Calculate the Levenshtein distance between two strings in PHP

Description

The following code shows how to calculate the Levenshtein distance between two strings.

Example


  /*from ww  w .j  a  va 2  s  .  com*/
<?php
    echo levenshtein("Hello World","ello World");
    echo "<br>";
    echo levenshtein("Hello World","ello World",10,20,30);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone