1. Get the keyword according to the weight
Copy Code code as follows:
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 ("/<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 for you to get the keyword article
2. Remove the hyperlinks in the article simple, concise
Copy Code code as follows:
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 The text in the->plaintext;//link;
$link->outertext = $text;
}
$now _content = $html->save ();
}
Preg_replace ("/<a .*?> (. *?) <\/a>/i "," \${1} ", $content); It can also be used in the same way