This tutorial will enable you to use BBCode (Bulletin Board Code) in either your own custom made forums, guestbooks or similar projects.
Step 1
For this example I'll start with a simple varible for the text, however you may have the text coming from the database.
Step 2
Now we have the message as a variable I will show you how to turn the odd bits of stuff like [i][/i] and [b][/b] into formatted text. Below you will see an addition to my text that was entered above and that extra bit is basically the PHP to turn it from normal random weird text to HTML formatted text.
The varible "$message" has been passed through all the coding and now to show it on a page all you have to do is print the "$message" varible.
Step 3
Now all you need to do is simply show the "updated" $message varible, by just printing it.
Your text should now have had changed into nicely formatted text. Like this: Hello, my name is Dale Hay.
Comments
Comments:
20th Jun 2007 20:13
Hi
By Ramin
21st Jun 2007 14:49
erm.. Hi.
By Dale Hay
25th Jun 2007 14:20
dude
By hey
17th Sep 2007 10:27
I just want to thankyou, I have been looking for a easy way and this help me out so much, all other bbcode script are so confusing, xudas.com TY!!!
By insanemonkey
17th Sep 2007 19:27
Glad it helped you "insanemonkey". I take it this is what you're using on your Xudas Forum?
By Dale Hay
17th Sep 2007 23:50
Wouldn't it be easier to use
preg_replace()
It would be faster and more flexible also.
By Marc N.
22nd Sep 2007 9:41
Using preg_replace() is yes, an easier way to do it however some people may get confused where to add the (*.?) or \1 stuff.
I did Conrad, as the one on that site is from the comment replier "insanemonkey" who replied on the 17th September. That article you're pointing to was wrote on the 17th October ... a whole month later.