当前位置 : 主页 > 网络编程 > PHP >

PhP比较字符串相似度

来源:互联网 收集:自由互联 发布时间:2021-06-30
[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, $percen

[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();
}
?>
网友评论