Php filters other website links in html (the domain name whitelist function ). The code for copying the code is as follows: *** filter out the origin site link * @ paramarray $ local_domain this site domain name array * @ paramstring $ message text content * functionreplace_outer_links ($ local_do
The code is as follows:
/**
* Filter out site links
* @ Param array $ local_domain this site domain name array
* @ Param string $ message text content
*/
Function replace_outer_links ($ local_domain_arr, $ message ){
$ Pattern = '/<[^>] * href = [\' \ "] http [s]? :\/\/(?! ';
$ I = 0;
Foreach ($ local_domain_arr as $ local_domain ){
If ($ I = 0 ){
$ Pattern. = 'www. '. $ local_domain.' | '. $ local_domain.' | [\ w \ _] + \. '. $ local_domain;
} Else {
$ Pattern. = '| www.'. $ local_domain. '|'. $ local_domain. '| [\ w \ _] + \.'. $ local_domain;
}
$ I ++;
}
$ Pattern. = ') [^ \' ^ \ "] * [\ '\"] [^>] *> (. + ?) <\/A>/is ';
Return preg_replace ($ pattern, '$ 1', $ message );
}
The http://www.bkjia.com/PHPjc/760287.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/760287.htmlTechArticle code is as follows:/*** filter out site link * @ param array $ local_domain this site domain name array * @ param string $ message text content */function replace_outer_links ($ local_do...