Jump to content

Archived

This topic is now archived and is closed to further replies.

oracle259

need help with similar_text()

Recommended Posts

How can i combine the similar_text() and levenshtein() functions to get a more accurate match percentage than similar_text()

I tried

[code]

$match = similar_text($word1, $word2, $percent);
$percent = round($percent, 1);

if ($percent > 5) {

$lev = levenshtein($word1, $word2);
$count1 = strlen($word1);
$count2 = strlen($word2);
$cnt = ($count1/$count2) * $lev;
$cnt = round($cnt, 1);

if ($cnt > 1) {
echo "fail";
} else {
echo "pass";
}
} else {
echo "pass";
}

[/code]

but it fails to pass ass in asset because $percent = 0 and $cnt = 1.5

Please help

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.