Skip to content

Instantly share code, notes, and snippets.

@Raffaello
Last active April 16, 2016 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raffaello/9907ab9d160911566344a894e4b3e793 to your computer and use it in GitHub Desktop.
Save Raffaello/9907ab9d160911566344a894e4b3e793 to your computer and use it in GitHub Desktop.
typo suggestion
function suggestion(array $words, $word)
{
$lev = [];
foreach ($words as $w) {
$lev[$w] = levenshtein($word, $w);
}
return array_search(min($lev), $lev, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment