Automatically extract article content keywords in php function method of SEO optimized website
The paper uses the basic condition of discuz to extract the keywords automatically, and then optimizes the function method of the chain in the website . The key word extracted by this method is close
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= $qc _ROWS&ICS=GBK&OCS=GBK ")); Preg_match_all ("/
(. *) a\[(. *) \]\] (. *) ><\/kw>/", $data, $out, preg_set_order); $key = ""; for ($i =0, $i <5; $i + +) {$key = $key. $out [$i][2];if ($out [$i][2]) $key = $key. ",";} return $key; }
?
Method Two: This method extracts the keyword relative to the top of a little bit
function Getkey ($contents) {$key = "; $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; }
?
Haikou? http://www.souhaikou.com