0
取代我在互聯網上找到了一些腳本來設置高亮像[B]替換HTML從數據庫設置高亮
function bbcodehtml($bbtext){
$bbtags = array(
'[b]' => '<strong>','[/b]' => '</strong>',
'[i]' => '<em>','[/i]' => '</em>',
'[u]' => '<span style="text-decoration: underline;">', '[/u]' => '</span>',
'[code]' => '<blockquote>','[/code]' => '</blockquote>'
);
$bbtext = str_ireplace(array_keys($bbtags), array_values($bbtags), $bbtext);
$bbextended = array(
"/\[url](.*?)\[\/url]/i" => "<a target=\"_blank\" href=\"http://$1\" title=\"$1\">$1</a>",
"/\[url=(.*?)\](.*?)\[\/url\]/i" => "<a target=\"_blank\" href=\"$1\" title=\"$1\">$2</a>",
"/\[img\]([^[]*)\[\/img\]/i" => "<img style=\"max-width:700px;\" src=\"$1\" alt=\" \" />",
"/\[image\]([^[]*)\[\/image\]/i" => "<img style=\"max-width:700px;\" src=\"$1\" alt=\" \" />"
);
foreach($bbextended as $match=>$replacement){
$bbtext = preg_replace($match, $replacement, $bbtext);
}
return $bbtext;
}
但現在我從當我要顯示在textarea的內容我不能代替HTML的BBcodes有。 。 我試圖改變值preg_replace
和我得到的錯誤..
嗨,歡迎來到SO。請添加代碼的重要部分(可能有錯誤)。請閱讀[如何提問](http://stackoverflow.com/help/how-to-ask)和[mcve](http://stackoverflow.com/help/mcve)以獲取更好的收到問題。也請在這裏放置您的錯誤。 – davejal