php实现转换ubb代码的方法

function ubb2html($content) { global $article; //是否自动识别 if ($article['isparseurl'] == "1") { $content = parseurl($content); } //自动识别结束 $content = eregi_replace(quotemeta("[b]"),quotemeta("<b>"),$content); $content = eregi_replace(quotemeta("[/b]"),quotemeta("</b>"),$content); $content = eregi_replace(quotemeta("[i]"),quotemeta("<i>"),$content); $content = eregi_replace(quotemeta("[/i]"),quotemeta("</i>"),$content); $content = eregi_replace(quotemeta("[u]"),quotemeta("<u>"),$content); $content = eregi_replace(quotemeta("[/u]"),quotemeta("</u>"),$content); $content = eregi_replace(quotemeta("[center]"),quotemeta("<center>"),$content); $content = eregi_replace(quotemeta("[/center]"),quotemeta("</center>"),$content); $content = eregi_replace(quotemeta("[quote]"),quotemeta("<table width=https://www.jb51.net/article/\"96%\" border=https://www.jb51.net/article/\"0\" cellspacing=https://www.jb51.net/article/\"3\" cellpadding=https://www.jb51.net/article/\"0\" style=word-break:break-all align=https://www.jb51.net/article/\"center\"><tr><td><b>引用:</b></td></tr><tr><td><hr width=https://www.jb51.net/article/\"100%\" noshade></td></tr><tr><td class=https://www.jb51.net/article/\"content\"><font color=https://www.jb51.net/article/\"#0000FF\">"),$content); $content = eregi_replace(quotemeta("[/quote]"),quotemeta("</font></td></tr><tr><td><hr width=https://www.jb51.net/article/\"100%\" noshade></td></tr></table>"),$content); $content = eregi_replace(quotemeta("

复制代码 代码如下:

"),quotemeta("<table width=https://www.jb51.net/article/\"96%\" border=https://www.jb51.net/article/\"0\" cellspacing=https://www.jb51.net/article/\"3\" cellpadding=https://www.jb51.net/article/\"0\" style=word-break:break-all align=https://www.jb51.net/article/\"center\"><tr><td><b>代码:</b></td></tr><tr><td><hr width=https://www.jb51.net/article/\"100%\" noshade></td></tr><tr><td class=https://www.jb51.net/article/\"code\"><font color=https://www.jb51.net/article/\"#0000FF\">"),$content); $content = eregi_replace(quotemeta("

"),quotemeta("</font></td></tr><tr><td><hr width=https://www.jb51.net/article/\"100%\" noshade></td></tr></table>"),$content); $content = eregi_replace("\\[images\\]([^\\[]*)\\[/images\\]","<a href=https://www.jb51.net/article/\"\\1\" target=https://www.jb51.net/article/\"_blank\"><img src=https://www.jb51.net/article/\"\\1\" border=0 onload=https://www.jb51.net/article/\"javascript:if(this.width>screen.width-333)this.width=screen.width-333\" title=https://www.jb51.net/article/\"用新窗口浏览原始图片\"></a>",$content); $content = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]", "<a href=https://www.jb51.net/article/\"http://www.\\1\" target=_blank>\\1</a>",$content); $content = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=https://www.jb51.net/article/\"\\1\" target=_blank>\\1</a>",$content); $content = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]","<a href=https://www.jb51.net/article/\"\\1\" target=_blank>\\2</a>",$content); $content = eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]", "<a href=https://www.jb51.net/article/\"mailto:\\1\">\\1</a>",$content); //$content = preg_replace( '/javascript/i', 'java script', $content); return $content; }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/4e14434e98a004b51b6c32f55568130c.html