1. Get keywords based on weights
Copy the 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 ("/ (. *) 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 the article you want to get the keyword
2. Remove the hyperlinks in the article simple, concise
Copy the 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>/i "," \${1} ", $content); It's also possible to use the regular
The above describes the keyword bulk query php self-write function code to get the keyword to hyperlink, including the keyword batch query content, I hope that the PHP tutorial interested in a friend helpful.