| | THIS BBCODE TUTORIAL was found to be copied. -- TUTORIAL EDITED -- |
|
|
|
This tutorial is really usefull for PHP programmers. I suggest including the original RegEx thingy before the PregEx thingy. Did you get what I said? It's really hard to explain. Again, this is a really usefull tutorial! Good job!
I'm not really sure what you mean exactly, but the regex have to be designed before the preg_replace() call
Very nice, I always wondered what the stuff in preg_replace meant.
Thanks for the great tutorial, this has helped me a ton!
One thing I would recommend adding however is the i modifier. This will make the bbcode case insensitive. For example: Bold and Bold will both be changed instead of just the first one. To do this, add an "i" after the last slash in each line of the regex statement. Example: $regexes = array( "/\[b\]([\D\S]+?)\[\/b\]/i" "/\[i\]([\D\S]+?)\[\/i\]/i" "/\[u\]([\D\S]+?)\[\/u\]/i" "/\[url=(?:http:\/\/)?([\/0-9a-zA-Z._-]+)\]([\D\S]+?)\[\/url\]/i" "/\[img\]([\D\S]+?)\[\/img\]/i" );
Excellent work. Good for people trying to make their own CMS'es/Forums/etc, straight out the ground with PHP.
Panda CODE [colorx=red]red text[colorx=blue]blue text[/colorx]back to red[/colorx] We "want" this result: <font color="red">red text<font color="blue">blue text</font>back to red</font> However, this is the result that the code produces: CODE <font color="red">red text[colorx=blue]blue text</font>back to red[/colorx] (note: I used 'colorx' instead of 'color' so the forum would not parse the code) For the record, different nested codes work, such as italics within bold, but like codes dont work, such as a bold inside of a bold, quote inside of a quote, color inside of a color, etc.
CODE $formated = preg_replace($regexes, $replacements, $text); You lost me here why do you have to replace the reg in the first place cant you just add a simple image edit to the end to save you the time and trouble of having to update and resend all the information when you go to add a image to the main root?
Nice tutorial I always wondered how to do that. Now if someone comes up with some good html it can be used for their forum.
Woah...
I've always wondered how BB Code was implemented, that's pretty cool. And yeah, somehow I never knew what preg_replace did...I hadn't even heard about it that much before I read this. Wow, nice tutorial and thanks for the help.
Recent Queries:-
Keywords : ultimate, bbcode, b, quote, img, smilies
Make smilies for your forums! (3) Wanna make your own pixel smilies! For cutenews, your forums, websites, etc.. What you need: A (11) Ever wanted to create your own smilies! This is the tool palette. I've highlighted the adding extra tags in a Simple Machines Forum (0) Adding custom BBCodes to your Simple Machines Forum is really very... simple. First, you will need (6) Here's a little random quote script that you can use to randomly choose from an array of quotes Looking for ultimate, bbcode, b, quote, img, smilies
|
|
![]() Ultimate Bbcode Tutorial - [b ],[ i],[u],[quote ],[img ],smilies |
| ADD REPLY / Got an Opinion! | Remove these ADs! | RAPID SEARCH! | Free Web Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute more info. to help others. Ask your Doubts & Queries to get answers, So that "Together We can help others!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|