PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
function BBCODE($content){ //define the function of bbcode
$content = nl2br($content); //replaces returns with br's
$match = array(
'#\[b\](.*?)\[\/b\]#se',
'#\[i\](.*?)\[\/i\]#se',
'#\[u\](.*?)\[\/u\]#se',
'#\[url=(.*?)\](.*?)\[\/url\]#se',
'#\[url\](.*?)\[\/url\]#se',
'#\[img\](.*?)\[\/img\]#se',
'#\[code\](.*?)\[\/code\]#se',
'#\[php\](.*?)\[\/php\]#se',
'#\[html\](.*?)\[\/html\]#se',
'#\[print\](.*?)\[\/print\]#se'
); //codes used in posts
$replace = array(
"'<b>\\1</b>'",
"'<i>\\1</i>'",
"'<u>\\1</u>'",
"'<a href=\"\\1\" target=\"_BLANK\">\\2</a>'",
"'<a href=\"\\1\" target=\"_BLANK\">\\1</a>'",
"'<img border=\"0\" src=\"\\1\">'",
"'<u><b>Code:</b></u>
<div style=\"border: 1px dotted #000000; width: 370px; background-color: #CCCCCC;\">
'.highlight_string(stripslashes(str_replace('', '', '$1')), true).'</div>'",
"'<u><b>PHP Code:</b></u>
<div style=\"border: 1px solid #42AC47; width: 370px;background-color: #B1E2B4;> '.highlight_string(stripslashes(str_replace('', '', '$1')), true).'</div>'",
"'<u><b>HTML Code:</b></u>
<div style=\"border: 1px solid #42AC47; width: 370px;background-color: #CCCCCC;> '.highlight_string(stripslashes(str_replace('', '', '$1')), true).'</div>'",
"'<u><b>Print Out:</b></u>
<div style=\"border: 1px dotted #000000; width: 370px; background-color: #CCCCCC;>
'.highlight_string(stripslashes(str_replace('', '', '$1')), true).'</div>'"
); //replacements
return preg_replace($match, $replace, $content); //match, and replace
} //end the function
then go down a little more. Replace
And you are done. That BBcode should appear above the message body and below the message title. Enjoy.