php 自写函数代码 获取关键字 去超链接
前端之家收集整理的这篇文章主要介绍了
php 自写函数代码 获取关键字 去超链接,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_0@1.根据权重获取关键字
<div class="codetitle"><a style="CURSOR: pointer" data="80302" class="copybut" id="copybut80302" onclick="doCopy('code80302')"> 代码如下:
<div class="codebody" id="code80302">
function getkey($contents){
$rows = strip_tags($contents);
$arr = array(' ','',"\s","\r\n","\n","\r","\t",">","“","”");
$qc_rows = str_replace($arr,$rows);
if(strlen($qc_rows)>2400){
$qc_rows = substr($qc_rows,'0','2400');
}
$data = @implode('',file("
http://keyword.discuz.com/related_kw.html?title=$contents&ics=gbk&ocs=gbk"));
preg_match_all("/
(.)A[(.)]](.)><\/kw>/",$data,$out,PREG_SET_ORDER);
for($i=0;$i<5;$i++){
$key=$key.$out[$i][2];
if($out[$i][2])$key=$key.",";
}
return $key;
}
//$contents为你要得到关键字的文章