php自己書き込み関数コードキーワードのハイパーリンク取得

1429 ワード

1.重みに基づいてキーワードを取得
 
  
function getkey($contents){
$rows = strip_tags($contents);
$arr = array(' ',' ',"\s", "\r
", "
", "\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<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("/(.*?)/i","${1}",$content);このように でもよい