作者:laknm_456 | 来源:互联网 | 2018-07-16 23:35
ec(2);phpubb转换成html,html转换成ubb代码functionhtmlToUBB($str){ $strpreg_replace("<img[^>]+src"([^"]+)"[^>]*>i","[img]$1[img]",$str);&nbs
php ubb转换成html,html转换成ubb代码
function htmlToUBB($str)
{
$str = preg_replace("/]+src="([^"]+)"[^>]*>/i","[img]$1[/img]",$str);
$str = preg_replace("//i","[video]$1[/video]",$str);
return $str;
}
function UBB($str)
{
$auto_arr = array(
"/(?<=[^]a-z0-9-="'\/])((https?|ftp|mms|rtsp)://)([a-z0-9/-_+=.~!%@?#%&;:$\│]+)/i",
"/(?<=[^]a-z0-9/-_.~?=:.])([_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4}))/i",
"/[img](.+?)[/img]/is",
"/[video](.+?)[/video]/is"
);
$auto_url = array(
'\1\3',
'\0',
'',
''
);
$str = preg_replace($auto_arr,$auto_url," ".$str);
$str = nl2br($str);
return $str;
}