PhP比较字符串相似度

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

[PHP]代码

<?php 
require('conn.php');
$sql="select title from content order by id desc limit 20"; //判断标题相似度
$result=mysql_query($sql,$conn);
$cf=0;
while($row=mysql_fetch_array($result)){
similar_text($row['title'], $title, $percent); //比较相似度 存放于$percent
if($percent>90){$cf=1;break;} //飘易注:相似度高于90% 则判断重复
}
if($cf==1){
echo "<SCRIPT language=JavaScript>alert('抱歉!禁止发布重复信息!');";
echo "this.location.href='vbscript:history.back()';</SCRIPT>";
mysql_close();
exit();
}
?>