PHP is replacing non-site links
<?PHP//The text to replace, such as the text in the product descriptionHeader("content-type:text/html; Charset=utf-8 "); $content=<li><a href= "http://afish.cnblogs.com" target= "_blank" > Small fish Court </a></li><li><a href= "http://afish.cnblogs.com" target= "_blank" > small fish Court </a></li><li><a href= "http:/ /afish.cnblogs.com "target=" _blank "> small fish Court </a></li><li><a href="/http Www.baidu.com "target=" _blank "> Baidu </a></li><li><a href=" http://www.baidu.com "target=" _ Blank "> Baidu </a></li><li><a href=" http://www.baidu.com "target=" _blank "> Baidu </a>< /li><li><a href= "http://www.soso.com" target= "_blank" > Search </a></li><li><a href= "Http://www.soso.com" target= "_blank" > Search </a></li><li><a href= "http://www.soso.com" target = "_blank" > Search </a></li>‘;//the site domain name$host _url=Str_replace(".", "\.",Str_replace("www.", "",$_server[' Http_host ']));//Echo $host _url;//replacement Regular$pattern= '/<[^>]*href=[\ ' \ ']http?:\ /\/(?!‘.Str_replace("/http", "",$host _url). ' | '.Str_replace("http://www.", "",$host _url). ' | [\w\_]+\.]Str_replace("http://www.", "",$host _url).‘) [^\ ' ^\ ']*[\ ' \ '][^>]*> (. +?) <\/a>/is ';//Replace the content//$replace = ' <a href= ' http://'. $_server[' http_host '. ' target= ' _blank ' >$1</a> ';$replace= ' <a href= ' http://'.$_server[' Http_host ']. ' " target= "_blank" > Site link </a> ';//to replace$content=Preg_replace($pattern,$replace,$content);//output the replaced contentEcho $content;?>
PHP regular replacement non-station internal chain replacement Zencart description of non-site links