php_begins Posted September 12, 2011 Share Posted September 12, 2011 Right now i used the following code to convert bbcode to html/php. i also need to incorporate QUOTE=name and URLS as well..how do i do that? function bbcode_format ($str) { $str = htmlentities($str); $start = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[a\=(.*?)\](.*?)\[\/a\]/is', '/\[color\=(.*?)\](.*?)\[\/color\]/is', '/\[img\](.*?)\[\/img\]/is', '/\[header\](.*?)\[\/header\]/is' ); $finish = array( '<strong>$1</strong>', '<em>$1</em>', '<u>$1</u>', '<a href="$1">$2</a>', '<span style="color: $1">$2</span>', '<img src="$1" />', '<span class="h3">$1</span>' ); $str = preg_replace ($start, $finish, $str); return $str; } Quote Link to comment https://forums.phpfreaks.com/topic/247012-bbcode-function/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.