2012-02-24 64 views
0

如果我有一些像这样的代码:如何将BBcode网址转换为PHP链接?

[url=http://google.com]Google[/url] 
[url=google.com]Google[/url] 
[url]http://google.com[/url] 
[url=https://google.com]Google secure[/url] 

如何将它们与一个转换的preg_replace此:

<a target="_blank" href="http://google.com">Google</a> 
<a target="_blank" href="http://google.com">Google</a> 
<a target="_blank" href="http://google.com">http://google.com</a> 
<a target="_blank" href="https://google.com">Google Secure</a> 

我搜索了很多,但我还没有发现任何有用的东西。 在此先感谢。

+0

我喜欢*“有一个preg_replace”*部分你的问题最。我只接受在黑色背景上使用粉色和紫色的代码突出显示的答案。有时请画一条彩虹。 – hakre 2012-02-24 22:56:51

回答