时间:2021-07-01 10:21:17 帮助过:33人阅读
function similarity($a,$b)
{
$a_arr=explode(',',$a);
$b_arr=explode(',',$b);
$num=count(array_intersect($a_arr,$b_arr));
$count=count($a_arr);
return ($num/$count*100).'%';
}
$a="1,2,3,4,5";
$b="1,2,3,4,6";
$c="1,2,4,5,6";
$d="2,3,4,5,6";
$f="7,8,9,10,11";
echo similarity($a,$b).'
';
echo similarity($a,$c).'
';
echo similarity($a,$d).'
';
echo similarity($a,$f).'
';