Home > Backend Development > PHP Tutorial > 自己写的一个UBB转换的函数_PHP

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 12:32:02
Original
1157 people have browsed it

function ubb2xhtml($ubb)
{
$flash= codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="%1\$d" height="%2\$d">




END;
$match = array
(
'%\[url=([^\s] )\](.*?)\[/url\]%s',
'%\[email=([^\s]) \](.*?)\[/email\]%i',
'%\[img width=(\d ) height=(\d )\](.*?)\[/img\]%s',
'%\[img=([^\s] )\/\]%s',
'%\[flash width=(\d ) height=(\d )\](.*?)\[/flash\]%se',
'%\[(b|i|u|strike|sup|sub)\](.*?)\[/\1\]%s',
'%\[h([1-6])\](.*?)\[/h\1\]%s',
'%\[hr\/\]%s',
'%\[color=([^\s] )\](.*?)\[/color\]%s',
'%\[font=([^\"] )\](.*?)\[/font\]%s',
'%\[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转换的函数_PHP',
'自己写的一个UBB转换的函数_PHP',
'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 Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template