Jul 25, 2008

Ultimate Bbcode Tutorial - [b ],[ i],[u],[quote ],[img ],smilies

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

Ultimate Bbcode Tutorial - [b ],[ i],[u],[quote ],[img ],smilies

scheme
THIS BBCODE TUTORIAL was found to be copied.

-- TUTORIAL EDITED --

Reply

karlo
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! smile.gif

Reply

scheme
I'm not really sure what you mean exactly, but the regex have to be designed before the preg_replace() call

Reply

beeseven
Very nice, I always wondered what the stuff in preg_replace meant.

Reply

MXBrandon
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"
);

Reply

thablkpanda
Excellent work. Good for people trying to make their own CMS'es/Forums/etc, straight out the ground with PHP.

Panda

Reply

MXBrandon
Is there a way make nested codes work? For example, using the code provided above, if someone types in this:

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.

Notice from cmatcmextra:
Please use CODE tags when writing codes. Doing this also prevents the forums from parsing bbcoding.

 

 

 


Reply

dundun2007
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?

Reply

wariorpk
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.

Reply

Revolutionary.
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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. bb code tutorial - 2.62 hr back. (1)
  2. parse bbcode examples - 8.99 hr back. (1)
  3. bbcode making smilies - 9.12 hr back. (1)
  4. bbcode quote within quote reference - 9.55 hr back. (1)
  5. bbcode example - 13.24 hr back. (1)
  6. bcc code tutorial - 27.86 hr back. (1)
  7. example code bb - 37.66 hr back. (1)
  8. bb code smileys - 41.42 hr back. (1)
  9. bb code tutorials - 42.21 hr back. (1)
  10. bbcode smileys - 11.30 hr back. (2)
  11. free bbcode - 52.86 hr back. (1)
  12. bbcode tutorial - 25.22 hr back. (6)
  13. array tutorial bbcode - 64.27 hr back. (1)
  14. bbcode smilies - 75.97 hr back. (1)
Similar Topics

Keywords : ultimate, bbcode, b, quote, img, smilies

  1. How To Make An Ultimate Game List.
    If you're making a site on video games or such. (0)
  2. How To Create Forum Smilies
    Make smilies for your forums! (3)
    Wanna make your own pixel smilies! For cutenews, your forums, websites, etc.. What you need: A
    graphics program that allows you to zoom in very closely to an image (paint is OK... but not the
    best...) OPTIONAL... a program that has a grid when you zoom in (most graphics programs have them)
    I'll use a program called paint.NET START 1. Copy this image and paste into a graphics
    program 2. Then ZOOM so you can see the image close up. For easy use make sure it is in some sort
    of "grid mode" Example: 3. Draw your eyes, face, nose, ears, etc... Your *may*....
  3. Create Your Own Smilies.
    (11)
    Ever wanted to create your own smilies! This is the tool palette. I've highlighted the
    tools that you will be using for this tutorial. I've provided this as a reference to guide you
    as you progress through the tutorial. 1) Create a new document with the dimensions 15x15 and a
    transparent background. 2) Press the D key. This will reset your background and foreground colors
    to black and white. 3) Zoom in by either pressing CTRL + + or: Edit >> Zoom In, until you're at
    1600%. 4) Use your pencil tool to draw the following: 5) Use your Polygon....
  4. Custom Bbcode Tags In Smf
    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
    to download three mods from the package manager. Faster Parsecode, ModSettings Textarea, and of
    course Custom BB Code. Once you have those mods set up you will need to go into your admin section
    and click on your "Edit Features and Options" link. In the Basic Forum Features section you will now
    find a "Custom BB Code tags" box. This box is where you will put your custom codes. You can add as
    many as you like, one per line. Let's break down the bits of a simple tag tha....
  5. Random Quote Script
    (6)
    Here's a little random quote script that you can use to randomly choose from an array of quotes
    you provide. It's very easy to use on any page as it's an external script, you just call it
    from your page. I wouldn't use it for any more than about 50 quotes though, it would probably
    slow your site down too much. Here's the code: var ar = new Array(44) ar = "Do not meddle in
    the affairs of wizards, for they are subtle and quick to anger." ar = "Faithless is he that says
    farewell when the road darkens." ar = "I cordially dislike allegory in all its ....

    1. Looking for ultimate, bbcode, b, quote, img, smilies

Searching Video's for ultimate, bbcode, b, quote, img, smilies
advertisement



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