【www.gdgbn.com--php常用代码】

function get_ubb($text)//$text是文章内容
{//图片
$text=str_replace("[ img ]","",$text);

//链接地址
$arr=explode("[ /url ]",$text);
for($i=0;$i {$tt=explode("[ url ]",$arr[$i]);
$k=$tt[1];
$all=$all.$tt[0]."".$k."";
}
if(count($arr)==1)
{
$text=$text;}
else
{$no=count($arr)-1;
$text=$all.$arr[$no];}

//邮箱地址
$all="";
$arr=explode("[ /email ]",$text);
for($i=0;$i {$tt=explode("[ email ]",$arr[$i]);
$k=$tt[1];
$all=$all.$tt[0]."".$k."";
}
if(count($arr)==1)
{
$text=$text;}
else
{$no=count($arr)-1;
echo"$arr[$no]";
$text=$all.$arr[$no];}
return $text;
}
//调用
$text=get_ubb($text);
?>

本文来源:http://www.gdgbn.com/jiaocheng/11584/