手机
当前位置:查字典教程网 >编程开发 >php教程 >php 自写函数代码 获取关键字 去超链接
php 自写函数代码 获取关键字 去超链接
摘要:1.根据权重获取关键字复制代码代码如下:functiongetkey($contents){$rows=strip_tags($conten...

1.根据权重获取关键字

复制代码 代码如下:

function getkey($contents){

$rows = strip_tags($contents);

$arr = array(' ','',"s", "rn", "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("/<kw>(.*)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为你要得到关键字的文章

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("/<a .*?>(.*?)</a>/i","${1}", $content); 这样用正则也可以

【php 自写函数代码 获取关键字 去超链接】相关文章:

php 类自动载入的方法

php中关于socket的系列函数总结

图形数字验证代码

我的论坛源代码(六)

PHP5.2下preg_replace函数的问题

php代码优化及php相关问题总结

php-fpm 启动参数及重要配置详解

php eval函数一句话木马代码

php获取网页上所有链接的方法

php实现屏蔽掉黑帽SEO的搜索关键字

精品推荐
分类导航