Php self-writing function code obtains the keyword to hyperlink. 1. the code for copying keywords obtained by weight is as follows: functiongetkey ($ contents) {$ rowsstrip_tags ($ contents); $ arrarray (, s, rn, n, r, t ,,,);
1. get keywords based on weights
The code is 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) & gt; 2400 ){
$ Qc_rows = substr ($ qc_rows, '0', '123 ');
}
$ 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 the article for you to get the keyword
2. removing hyperlinks in the article is simple and concise
The code is 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-> plaintext; // text in the link;
$ Link-> outertext = $ text;
}
$ Now_content = $ html-> save ();
}
// Preg_replace ("/(.*?) <\/A>/I "," \ $ {1} ", $ content); you can also use regular expressions.
The response code is as follows: function getkey ($ contents) {$ rows = strip_tags ($ contents); $ arr = array ('','', "\ s ", "\ r \ n", "\ n", "\ r", "\ t ","","","");...