<p class="intro">php中将网址转换为超链接的函数,需要的朋友可以参考下。</p> <p id="con_all"> </p> <p id="con_ad1"></p> <p id="con_ad8"></p> 代码如下: <br>function showtext($text){ <br>$search = array('|(http://[^ ]+)|', '|(https://[^ ]+)|', '|(www.[^ ]+)|'); <br>$replace = array('<a href="%241" target="_blank">$1</a>', '<a href="%241" target="_blank">$1</a>', '<a href="http://%241" target="_blank">$1</a>'); <br>$text = preg_replace($search, $replace, $text); <br>return $text; <br>} <br>