Home >php教程 >php手册 >php实现转换ubb代码的方法

php实现转换ubb代码的方法

WBOY
WBOYOriginal
2016-06-06 20:03:141083browse

这篇文章主要介绍了php实现转换ubb代码的方法,涉及php正则替换的使用技巧,需要的朋友可以参考下

本文实例讲述了php实现转换ubb代码的方法。分享给大家供大家参考。具体如下:

function ubb2html($content) { global $article; //是否自动识别 if ($article['isparseurl'] == "1") { $content = parseurl($content); } //自动识别结束 $content = eregi_replace(quotemeta("[b]"),quotemeta(""),$content); $content = eregi_replace(quotemeta("[/b]"),quotemeta(""),$content); $content = eregi_replace(quotemeta("[i]"),quotemeta(""),$content); $content = eregi_replace(quotemeta("[/i]"),quotemeta(""),$content); $content = eregi_replace(quotemeta("[u]"),quotemeta(""),$content); $content = eregi_replace(quotemeta("[/u]"),quotemeta(""),$content); $content = eregi_replace(quotemeta("[center]"),quotemeta("

"),$content); $content = eregi_replace(quotemeta("[/center]"),quotemeta("
"),$content); $content = eregi_replace(quotemeta("[quote]"),quotemeta("
引用:

"),$content); $content = eregi_replace(quotemeta("[/quote]"),quotemeta("

"),$content); $content = eregi_replace(quotemeta("

复制代码 代码如下:

"),quotemeta("

代码:

"),$content); $content = eregi_replace(quotemeta(""),quotemeta("

"),$content); $content = eregi_replace("\\[images\\]([^\\[]*)\\[/images\\]","php实现转换ubb代码的方法screen.width-333)this.width=screen.width-333\" title=\"用新窗口浏览原始图片\">",$content); $content = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]", "\\1",$content); $content = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","\\1",$content); $content = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]","\\2",$content); $content = eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]", "\\1",$content); //$content = preg_replace( '/javascript/i', 'java script', $content); return $content; }

希望本文所述对大家的php程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn