您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 自写函数代码 获取关键字 去超链接

2025/4/29 20:35:48发布12次查看
根据权重获取关键字 去掉文章中的超链接简单,简洁
1.根据权重获取关键字
代码如下:
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\[(.*)\]\](.*)>/,$data, $out, preg_set_order);
for($i=0;$i$key=$key.$out[$i][2];
if($out[$i][2])$key=$key.,;
}
return $key;
}
//$contents为你要得到关键字的文章
2.去掉文章中的超链接简单,简洁
代码如下:
function get_new_content($content){
include(../simple_html_dom.php);
$html = str_get_html($content);
$a_href = $html->find('a');
foreach($a_href as $link){
$text = $link->plaintext;//链接中的文字;
$link->outertext = $text;
}
$now_content = $html->save();
}
//preg_replace(/(.*?)/i,\${1}, $content); 这样用正则也可以
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product