Home> php教程> php手册> body text

自己写的一个UBB转换的函数

WBOY
Release: 2016-06-21 09:05:30
Original
918 people have browsed it

ubb|函数|转换

function ubb2xhtml($ubb)
{
$flash=codebase="" width="%1\$d" height="%2\$d">


@#%\[size=([^\s]+)\](.*?)\[/size\]%s@#,
@#%\[align=(center|right|left)\](.*?)\[/align\]%s@#,
@#%\[valign=(middle|top|bottom)\](.*?)\[/valign\]%s@#,
/*
@#%\[ul\](.*?)\[/ul\]%s@#,
@#%\[ul=(circle|disc|square)\](.*?)\[/ul\]%s@#,
@#%\[ol\](.*?)\[/ol\]%s@#,
@#%\[ol type=([aAiI1]) start=([a-zA-Z1-9])\](.*?)\[/ol\]%s@#,
@#%\[li\](.*?)\[/li\]%s@#,
*/
@#%\[table=([^\s]+?)\](.*?)\[/table\]%s@#,
@#%\[caption\](.*?)\[/caption\]%s@#,
@#%\[tr=([^\s]+?)\](.*?)\[/tr\]%s@#,
@#%\[th\](.*?)\[/th\]%s@#,
@#%\[td\](.*?)\[/td\]%s@#,
@#%\[note\](.*?)\[/note\]%s@#,
@#%\[quote=(.*?)\](.*?)\[/quote\]%s@#,
@#%\[code\](.*?)\[/code\]%s@#,
@#%[ ]{2}%s@#, // make double-spaces truly double-spaces!
);
$replace = array
(
@#\2@#,
@#\2@#,
@#自己写的一个UBB转换的函数@#,
@#自己写的一个UBB转换的函数@#,
@#sprintf("$flash", "\1", "\2", "\3")@#,
@#\2\1>@#,
@# \2 \1>@#,
@#


\n@#,
@# \2@#,
@# \2@#,
@# \2@#,
@#
\2@#,
@#
\2@#,
/*
@#
    \1
@#,
@#
    \2
@#,
@#
    \1
@#,
@#
    \3
@#,
@#
  • \1
  • @#,
    */
    " \n$2
    ",
    "\t$1\n",
    "\t\n$2\t\n",
    "\t\t$1\n",
    "\t\t$1\n",
    @#
    发布者备注
    \1
    @#,
    @#
    引用(来源: \1)
    \2
    @#,
    @# 代码
    \1
    @#,
    @# @#,
    );
    if( preg_match(@#%\[table=(.*?)\/table\]%s@#, $ubb, $tablecells) ) //如果有表格, 先去除单元格之间的多余空白
    {
    $bb=preg_replace(@#%\]([\r\n\s]*)\[%si@#, @#][@#, $tablecells[1]);
    $ubb=str_replace($tablecells[1], $bb, $ubb);
    }
    $html = preg_replace($match, $replace, nl2br(htmlspecialchars($ubb)));
    $html = preg_replace(@#/
    \s* return $html;
    }



    Related labels:
    source:php.cn
    Statement of this Website
    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
    Popular Recommendations
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!