在字符串中把网址改成超级链接

$string = "连接http://www.phpx.com 站点";
//连接后需要有个空格或回车。

$string = eregi_replace("http://([^ ,\r\n]*)","

1<a href="\\\0" target="_blank">\\\0</a>

",$string);
$string = eregi_replace("ftp://([^ ,\r\n]*)","

1<a href="\\\0" target="_blank">\\\0</a>

",$string);

print $string;

这个可是非常有用的呀.

Published At
Categories with Web编程
Tagged with
comments powered by Disqus