php UBB 解析实现代码
作者:bea
代码如下: /** +---------------------------------------------------------- * UBB 解析 +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ function ub
代码如下:
/**
+----------------------------------------------------------
* UBB 解析
+----------------------------------------------------------
* @return string
+----------------------------------------------------------
*/
function ubb($Text) {
$Text=trim($Text);
$Text=ereg_replace("
","<br>",$Text);
$Text=preg_replace("/\t/is"," ",$Text);
$Text=preg_replace("/[hr]/is","<hr>",$Text);
$Text=preg_replace("/[separator]/is","<br/>",$Text);
$Text=preg_replace("/[h1](.+?)[/h1]/is","<h1>\1</h1>",$Text);
$Text=preg_replace("/[h2](.+?)[/h2]/is","<h2>\1</h2>",$Text);
$Text=preg_replace("/[h3](.+?)[/h3]/is","<h3>\1</h3>",$Text);
$Text=preg_replace("/[h4](.+?)[/h4]/is","<h4>\1</h4>",$Text);
$Text=preg_replace("/[h5](.+?)[/h5]/is","<h5>\1</h5>",$Text);
$Text=preg_replace("/[h6](.+?)[/h6]/is","<h6>\1</h6>",$Text);
$Text=preg_replace("/[center](.+?)[/center]/is","<center>\1</center>",$Text);
//$Text=preg_replace("/[url=([^[]*)](.+?)[/url]/is","<a href=\1 target='_blank'>\2</a>",$Text);
$Text=preg_replace("/[url](.+?)[/url]/is","<a href="\1" target='_blank'>\1</a>",$Text);
$Text=preg_replace("/[url=(http://.+?)](.+?)[/url]/is","<a href='\1' target='_blank'>\2</a>",$Text);
$Text=preg_replace("/[url=(.+?)](.+?)[/url]/is","<a href=\1>\2</a>",$Text);
$Text=preg_replace("/[img](.+?)[/img]/is","<img src=\1>",$Text);
$Text=preg_replace("/[imgs(.+?)](.+?)[/img]/is","<img \1 src=\2>",$Text);
$Text=preg_replace("/[color=(.+?)](.+?)[/color]/is","<font color=\1>\2</font>",$Text);
$Text=preg_replace("/[colorTxt](.+?)[/colorTxt]/eis","color_txt('\1')",$Text);
$Text=preg_replace("/[style=(.+?)](.+?)[/style]/is","<div class='\1'>\2</div>",$Text);
$Text=preg_replace("/[size=(.+?)](.+?)[/size]/is","<font size=\1>\2</font>",$Text);
$Text=preg_replace("/[sup](.+?)[/sup]/is","<sup>\1</sup>",$Text);
$Text=preg_replace("/[sub](.+?)[/sub]/is","<sub>\1</sub>",$Text);
$Text=preg_replace("/[pre](.+?)[/pre]/is","<pre>\1</pre>",$Text);
$Text=preg_replace("/[emot](.+?)[/emot]/eis","emot('\1')",$Text);
$Text=preg_replace("/[email](.+?)[/email]/is","<a href='mailto:\1'>\1</a>",$Text);
$Text=preg_replace("/[i](.+?)[/i]/is","<i>\1</i>",$Text);
$Text=preg_replace("/[u](.+?)[/u]/is","<u>\1</u>",$Text);
$Text=preg_replace("/[b](.+?)[/b]/is","<b>\1</b>",$Text);
$Text=preg_replace("/[quote](.+?)[/quote]/is","<blockquote>引用:<div style='border:1px solid silver;background:#EFFFDF;color:#393939;padding:5px' >\1</div></blockquote>", $Text);
$Text=preg_replace("/[code](.+?)[/code]/eis","highlight_code('\1')", $Text);
$Text=preg_replace("/[php](.+?)[/php]/eis","highlight_code('\1')", $Text);
$Text=preg_replace("/[sig](.+?)[/sig]/is","<div style='text-align: left; color: darkgreen; margin-left: 5%'><br><br>--------------------------<br>\1<br>--------------------------</div>", $Text);
return $Text;
}
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- PHPWind与Discuz截取字符函数substrs与cutstr性能比较
- php的chr和ord函数实现字符加减乘除运算实现代码
- PHP函数篇之掌握ord()与chr()函数应用
- PHP函数篇详解十进制、二进制、八进制和十六进制转换函数说明
- PHP详解ASCII码对照表与字符转换
- Ajax实时验证用户名/邮箱等是否已经存在的代码打包
- PHP循环语句笔记(foreach,list)
- openPNE常用方法分享
- 使用php+Ajax实现唯一校验实现代码[简单应用]
- php从右向左/从左向右截取字符串的实现方法
- PHP的array_diff()函数在处理大数组时的效率问题
- PHP 中检查或过滤IP地址的实现代码
- PHP中usort在值相同时改变原始位置问题的解决方法
- PHP中strtotime函数使用方法详解
- 遍历指定目录下的所有目录和文件的php代码
- 用PHP写的基于Memcache的Queue实现代码
- PHP中去除换行解决办法小结(PHP_EOL)
- php操作SVN版本服务器类代码
- 支持中文的php加密解密类代码