Jump to content

[SOLVED] bb code help


SyncViews

Recommended Posts

Ive made these to process bb codes:

<?php
$bb_codes = array(
'/\[b\](.*?)\[\/b\]/is',                              //BOLD
'/\[i\](.*?)\[\/i\]/is',                              //ITALIC
'/\[u\](.*?)\[\/u\]/is',                              //UNDERLINE
'/\[url\](.*?)\[\/url\]/is',                          //URL
'/\[url\=(.*?)\](.*?)\[\/url\]/is',                   //URL2
'/\[img\](.*?)\[\/img\]/is',                          //IMAGE
'/\[mail\](.*?)\[\/img\]/is',                         //MAIL
'/\[mail\=(.*?)\](.*?)\[\/mail\]/is',                 //MAIL2
'/\[colo?r\=(.*?)\](.*?)\[\/colo?r\]/is',             //COLOUR
'/\[size\=(.*?)\](.*?)\[\/size\]/is',                 //SIZE
'/\[font\=(.*?)\](.*?)\[\/font\]/is',                 //FONT
'/\[align\=(left|center|right)\](.*?)\[\/align\]/is', //ALIGN
'/\[pre\](.*?)\[\/pre\]/is'                           //PREFORMATTED
);

$bb_html = array(
'<span style="font-weight: bold">$1</span>',          //BOLD
'<span style="font-style: italic">$1</span>',         //ITALIC
'<span style="text-decoration: underline">$1</span>', //UNDERLINE
'<a href="$1">$1</a>',                                //URL
'<a href="$1">$2</a>',                                //URL2
'<img src="$1" alt="$1" />',                          //IMAGE
'<a href="mailto:$1">$1</a>',                         //MAIL
'<a href="mailto:$1">$2</a>',                         //MAIL2
'<span style="color: $1">$2</span>',                  //COLOUR
'<span style="font-size: $1">$2</span>',              //SIZE
'<span style="font-family: $1">$2</span>',            //FONT
'<span style="text-align: $1">$2</span>',             //ALIGN
'<pre>$1</pre>'                                       //PREFORMATTED
);
$str = preg_replace ($bb_codes, $bb_html, $str);
?>

 

 

The problem I'm havin is how to process the [code][/code] tags as I need to stop any of the other bbcodes effecting the code block.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.