PHP Self-write function code get keyword go hyperlink _php tips

Source: Internet
Author: User
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.