Jump to content

Creating tabs in codebox


KingOfHeart

Recommended Posts

I made a little codebox by using a


. Only problem is when I insert a code and need a tab, it does not create any.
Now I could just create a [tab] function but it would make long codes very annoying to add in.
Inside this codebox I'll be using tags so I can colorize certain words, otherwise I'd just use a pre tag. So how can I get tabs to show up as tabs but only inside of this code box.

function bbcode2html($message)
{
$bbcode = array(
"'\[center\](.*?)\[/center\]'is" => "<center>\\1</center>",
"'\[left\](.*?)\[/left\]'is" => "<div style='text-align: left;'>\\1</div>",
"'\[right\](.*?)\[/right\]'is" => "<div style='text-align: right;'>\\1</div>",
"'\[pre\](.*?)\[/pre\]'is" => "<pre>\\1</pre>",
"'\[b\](.*?)\[/b\]'is" => "<b>\\1</b>",
"'\[quote\](.*?)\[/quote\]'is" => "<div class='top'><b>Quote:</b><hr>\\1</div>",
"'\[i\](.*?)\[/i\]'is" => "<i>\\1</i>",
"'\[u\](.*?)\[/u\]'is" => "<u>\\1</u>",
"'\[s\](.*?)\[/s\]'is" => "<del>\\1</del>",
"'\[url\](.*?)\[/url\]'is" => "<a href='\\1' target='_BLANK'>\\1</a>",
"'\[url=(.*?)\](.*?)\[/url\]'is" => "<a href=\"\\1\" target=\"_BLANK\">\\2</a>",
"'\[img\](.*?)\[/img\]'is" => "<img border=\"0\" src=\"\\1\">",
"'\[img=(.*?)\]'" => "<img border=\"0\" src=\"\\1\">",
"'\[email\](.*?)\[/email\]'is" => "<a href='mailto: \\1'>\\1</a>",
"'\[size=(.*?)\](.*?)\[/size\]'is" => "<span style='font-size: \\1;'>\\2</span>",
"'\[font=(.*?)\](.*?)\[/font\]'is" => "<span style='font-family: \\1;'>\\2</span>",
"'\[color=(.*?)\](.*?)\[/color\]'is" => "<span style='color: \\1;'>\\2</span>",
"'\n'is" => "<br>",
"'\[list=o(.*?)\](.*?)\[/list\]'is" => "<ol>\\2</ol>",
"'\[list=u(.*?)\](.*?)\[/list\]'is" => "<ul>\\2</ol>",
"'\[li\](.*?)\[/li\]'is" => "<li>\\1</li>",
"'\[code\](.*?)\[/code\]'is" => "<div class='code'>\\1</div>",
);
$message = preg_replace(array_keys($bbcode), array_values($bbcode), $message);
return $message;
}

Link to comment
https://forums.phpfreaks.com/topic/233547-creating-tabs-in-codebox/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.