关于discuz的ubb转html的php方法

其实在discuz内置了这个函数,只是如果对接再去调用似乎有些麻烦,于是我把他放在一个包中,调用即可

<?php
class ubb2html {
function ubb($Text) {
$Text = preg_replace(array('/&amp;(#\d{3,5};)/', "/\[hide=?\d*\](.*?)\[\/hide\]/is", "/\[\/?\w+=?.*?\]/"), array('&\\1', '<b>**** Hidden Message *****</b>', ''), str_replace(array('&', '"', '<', '>', "\t", '   ', '  '), array('&amp;', '&quot;', '&lt;', '&gt;', '&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $Text));
return $Text;
}
}
?>

调用方法片段

$ubb = new ubb2html();
$uh = $ubb -> ubb($message);

Comments

No comments yet. Why don’t you start the discussion?

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注