Example 1 — Measure the Distance Between Two Words
The classic example: how far is kitten from sitting?
<?php
$distance = levenshtein("kitten", "sitting");
echo "Distance: " . $distance, PHP_EOL; How It Works
- Pick two words. They are kitten and sitting.
- Replace k with s. That is the first edit.
- Replace e with i, then add g. That makes edits two and three.
- Read the result. The distance is 3.

