0
嘿,所以我有一個聊天框爲我的網站,已經有一個笑臉功能內置到它,但沒有「詛咒過濾器」,所以我決定我會嘗試添加,今天。這是聊天框的輸出:如何解決在聊天中顯示錶情的小錯誤,並用聊天中的星號代替發誓?
$return .= "<div style=\"font-size: 14px; padding-bottom: 3px; color: #444444;\">". $time . $icon . $username . str_replace('"', "'", parse_bbcode(smiley(str_replace("\n", '', $chat['text'])))) ."</div>";
近的,它顯示了底:
str_replace('"', "'", parse_bbcode(smiley(str_replace("\n", '', $chat['text']))))
我已經取代笑臉與詛咒只是爲了測試它,並詛咒功能完美的作品,但我想知道如何讓笑臉和詛咒功能同時顯示,而不僅僅是一個或另一個。
我已經試過:
parse_bbcode(smiley, curses
parse_bbcode(smiley . curses
,但有沒有運氣....
這裏是我的parse_bbcode功能:
function parse_bbcode($text, $xhtml = true) {
$tags = array(
'#\[b\](.*?)\[/b\]#si' => ($xhtml ? '<strong>\\1</strong>' : '<b>\\1</b>'),
'#\[i\](.*?)\[/i\]#si' => ($xhtml ? '<em>\\1</em>' : '<i>\\1</i>'),
'#\[u\](.*?)\[/u\]#si' => ($xhtml ? '<span style="text-decoration: underline;">\\1</span>' : '<u>\\1</u>'),
'#\[s\](.*?)\[/s\]#si' => ($xhtml ? '<strike>\\1</strike>' : '<s>\\1</s>'),
'#\[color=(.*?)\](.*?)\[/color\]#si' => ($xhtml ? '<span style="color: \\1;">\\2</span>' : '<font color="\\1">\\2</font>'),
'#\[img\](.*?)\[/img\]#si' => ($xhtml ? '<img src="\\1" border="0" alt="" style="max-width: 400px; max-height: 200px;" />' : '<img src="\\1" border="0" alt="">'),
'#\[url=(.*?)\](.*?)\[/url\]#si' => '<a href="\\1" target="_blank" style="color: #000000; font-size: 12px;" title="\\2">\\2</a>',
'#\[email\](.*?)\[/email\]#si' => '<a href="mailto:\\1" title="Email \\1">\\1</a>',
'#\[code\](.*?)\[/code\]#si' => '<code>\\1</code>',
'#\[align=(.*?)\](.*?)\[/align\]#si' => ($xhtml ? '<div style="text-align: \\1;">\\2</div>' : '<div align="\\1">\\2</div>'),
'#\[br\]#si' => ($xhtml ? '<br style="clear: both;" />' : '<br>'),
);
foreach ($tags AS $search => $replace) {
$text = preg_replace($search, $replace, $text);
}
return $text;
}
我需要知道:您是否製作了自己的發誓過濾器或使用pre-ex是一個圖書館? – horatio