Home >php教程 >PHP源码 >PhP比较字符串相似度

PhP比较字符串相似度

PHP中文网
PHP中文网Original
2016-05-25 17:09:562499browse

PhP比较字符串相似度

<?php 
require(&#39;conn.php&#39;);
$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[&#39;title&#39;], $title, $percent); //比较相似度 存放于$percent
if($percent>90){$cf=1;break;} //飘易注:相似度高于90% 则判断重复
}
if($cf==1){
echo "<SCRIPT language=JavaScript>alert(&#39;抱歉!禁止发布重复信息!&#39;);";
echo "this.location.href=&#39;vbscript:history.back()&#39;;</SCRIPT>";
mysql_close();
exit();
}
?>

 以上就是PhP比较字符串相似度的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn