经测试代码如下:
/**
* BBCode替换函数
*
* @param
* @arrange (512.笔记) jb51.cc
**/
function BBcode($texto){
$a = array(
"/\[i\](.*?)\[\/i\]/is","/\[b\](.*?)\[\/b\]/is","/\[u\](.*?)\[\/u\]/is","/\[img\](.*?)\[\/img\]/is","/\[url=(.*?)\](.*?)\[\/url\]/is","/\[size=(.*?)\](.*?)\[\/size\]/is",);
$b = array(
"<i>$1</i>","<b>$1</b>","<u>$1</u>","<img src=\"$1\" />","<a href=\"$1\" target=\"_blank\">$2</a>",'<font size=$1>$2</font>',);
$texto = preg_replace($a,$b,$texto);
$texto = nl2br($texto);
return $texto;
}
if(isset($_GET['txt'])) {
echo "Has introducido: ".bbcode($_GET['txt']);
}
/*** 代码来自编程之家 jb51.cc(jb51.cc) ***/