Is it any function in PHP that check the % of similarity of two strings?
For example i have:
$string1=\"Hello how are you doing\"
$string2= \" hi,
As it's a nice question, I put some effort into it:
$l1) {
$t = $ar2;
$ar2 = $ar1;
$ar1 = $t;
}
//flip array 2, to make the words the keys
$ar2 = array_flip($ar2);
$maxwords = max($l1, $l2);
$matches = 0;
//find matching words
foreach($ar1 as $word) {
if (array_key_exists($word, $ar2))
$matches++;
}
return ($matches / $maxwords) * 100;
}
?>