dbradbury Posted January 13, 2010 Share Posted January 13, 2010 cant find my post tho, was gonna reply on there.. well i was getting information from a forum to show on my website. and when bbcode formatting was used in the forum, it didnt like it in html. it kept showing [b:473jbdgje] or something for , bolding. but i worked it out with internet surfing also.. i needed another file called bbcode.php <?php function bbcode ($string) { // All the default bbcode arrays. $bbcode = array( //Text Apperence '#\[b\](.*?)\[/b\]#si' => '<b>\\1</b>', '#\[i\](.*?)\[/i\]#si' => '<i>\\1</i>', '#\[u\](.*?)\[/u\]#si' => '<u>\\1</u>', '#\[s\](.*?)\[/s\]#si' => '<strike>\\1</strike>', //Font Color & Size '#\[color=(.*?)\](.*?)\[/color\]#si' => '<font color="\\1">\\2</font>', '#\[size=(.*?)\](.*?)\[/size\]#si' => '<font size="\\1">\\2</font>', //Text Effects '#\[bl\](.*?)\[/bl\]#si' => '<blink>\\1</blink>', '#\[marquee\](.*?)\[/marquee\]#si' => '<marquee>\\1</marquee>', //Other '#\[code\](.*?)\[/ code]#si' => '<div class="bbcode_code_title">CODE:</div><div class="bbcode_code_code">\\1<div>', '#\[url=http://(.*?)\](.*?)\[/url]#si' => '<a href="\\1" target="_blank">\\2</a>', '#\[quote\](.*?)\[/quote\]#si' => '<div class="bbcode_quote_title">CODE:</div><div class="bbcode_quote_quote">\\1<div>', '#\[img\](.*?)\[/img\]#si' => '<img src="\\1">', '#\[email\](.*?)\[/email\]#si' => '<a href="mailto:\\1">\\1</a>' ); $output = preg_replace(array_keys($bbcode), array_values($bbcode), $string); return $output; } ?> then on my actual page put a require("bbcode.php"); then where the text was displayed that used bbcode on the forum i had to put echo bbcode("THEN VARIABLE FOR THE TEXT HERE"); also i had to in my forum disable bbcode and smilies... altho im working on the smilies part... Link to comment https://forums.phpfreaks.com/topic/188340-i-asked-about-bbcode-to-html/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.