how do I make a bbcode to parse url tags into links?

空扰寡人 提交于 2019-12-02 06:31:34
yrosen
$post = preg_replace('/\[url=(.+?)\](.+?)\[\/url\]/', '<a href="\1">\2</a>', $post);

That will turn: [url=http://google.com]Google[/url]

Into parsed bbcode text: Google

You'll probably want to use more specific regex than just .+ to filter out potentially bad/dangerous input.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!