Keys →
Functions ↓
function in_dict ( $input, $dict ) {#-k search#- return the closest-sounding word to $input in $dict $shortest = -1; foreach ($dict as $word) { # loop through dictionary to find the closest $lev = levenshtein ( $input, $word ); # calculate the distance between the input word, and the current word if ($lev == 0) { # check for an exact match $closest = 0; # closest word is this one (exact match) break; # break out of the loop; we've found an exact match } if ($lev < $shortest || $shortest < 0) { $closest = $word; $shortest = $lev; } } return $closest; # 0 or the closest word }?>