문제

How can I return multiple similar matches with levenshtein in PHP? For example if I have this code:

$input = "Hello what is your name. My namer is Jack.";
$output = "nam";
echo levenshtein($input, $output);

It must not only output name, but name, namer.

How can I do that?

도움이 되었습니까?

해결책

Something like:

$input = "Hello what is your name. My namer is Jack.";
$output = "nam";
$threshold = 3;
foreach(str_word_count($input,1) as $word) {
    if (levenshtein($word, $output) < $threshold) {
        echo $word, PHP_EOL;
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top