2012-02-24 63 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

回答