this is how i want it =)
Edited by zYpher, 26 January 2006 - 12:27 AM.
Posted 26 January 2006 - 12:27 AM
this is how i want it =)
Edited by zYpher, 26 January 2006 - 12:27 AM.
Posted 26 January 2006 - 05:24 AM
function bbcode($string) {
$replace = array(
'@\[(?i)b\](.*?)\[/(?i)b\]@si',
'@\[(?i)url=(.*?)\](.*?)\[/(?i)url\]@si',
'@\[(?i)code\](.*?)\[/(?i)code\]@si'
);
$replacements = array ('<b>\\1</b>',
'<a href="\\1" target="_blank">\\2</a>',
'<div class="BBCode">Code:</div>
<div class="BBCode"> <font color=orange>\\1</font></div>'
);
$string = preg_replace($replace, $replacements, $string);
return $string;
}
'@\[(?i)b\](.*?)\[/(?i)b\]@si',the (?i) checks the CaSe of the word(s)
Posted 26 January 2006 - 12:14 PM
Posted 26 January 2006 - 04:10 PM
function bbcode($string){
$replace = array('#\[b\](.*?)\[/b\]#si',
'#\[url=(.*?)\](.*?)\[/url\]#si',
'#\[code\](.*?)\[/code\]#si');
$replacements = array ('<b>\\1</b>',
'<a href="\\1" target="_blank">\\2</a>',
'<div class="BBCode_title">Code:</div>'
.'<div class="BBCode_code">\\1</div>');
$string = preg_replace($replace, $replacements, $string);
return $string;
}
I removed the (?i)'s for the reason discussed here, and changed the html a bit. Basically, i changed the class names so he could have 1 css style defined for what is the red bar above the code, and another for the box containing the code. I also removed the font tag, not just because it's recommended you not use it, but because the BBCode_code style could also define any font styles you want, as well as the display of the box.
Posted 27 January 2006 - 11:36 AM
Quote
Quote
Posted 27 January 2006 - 09:01 PM
rc69, on Jan 26 2006, 09:10 PM, said:
function bbcode($string){
$replace = array('#\[b\](.*?)\[/b\]#si',
'#\[url=(.*?)\](.*?)\[/url\]#si',
'#\[code\](.*?)\[/code\]#si');
$replacements = array ('<b>\\1</b>',
'<a href="\\1" target="_blank">\\2</a>',
'<div class="BBCode_title">Code:</div>'
.'<div class="BBCode_code">\\1</div>');
$string = preg_replace($replace, $replacements, $string);
return $string;
}
I removed the (?i)'s for the reason discussed here, and changed the html a bit. Basically, i changed the class names so he could have 1 css style defined for what is the red bar above the code, and another for the box containing the code. I also removed the font tag, not just because it's recommended you not use it, but because the BBCode_code style could also define any font styles you want, as well as the display of the box.Posted 28 January 2006 - 03:59 AM
<?php
function parse ($string) {
$search = array(
'#\[([bB])](.+)\[/([bB])]#',
'#\[([iI])](.+)\[/([iI])]#',
'#\[([uU])](.+)\[/([uU])]#',
'#\[([cC][oO][dD][eE])](.+)\[/([cC][oO][dD][eE])]#',
'#\[([iI][mM][gG])](.+)\[/([iI][mM][gG])]#',
'#\[([uU][rR][lL])](.+)\[/([uU][rR][lL])]#',
'#\[([uU][rR][lL])=(.*)](.+)\[/([uU][rR][lL])]#',
'#\[([cC][oO][lL][oO][rR])=(red|green|blue)](.+)\[/([cC][oO][lL][oO][rR])]#',
'#\[([sS][iI][zZ][eE])=(1|2|3|4|5|6|7)](.+)\[/([sS][iI][zZ][eE])]#',
);
$replace = array(
'<b>$2</b>',
'<i>$2</i>',
'<u>$2</u>',
'<code>$2</code>',
'<img src="$2" />',
'<a href="$2">$2</a>',
'<a href="$2">$3</a>',
'<font color="$2">$3</font>',
'<font size="$2">$3</font>',
);
return preg_replace($search, $replace, $string);
}
?>
You can add more colors and different sizes in [color] and [size]
Posted 28 January 2006 - 01:13 PM
0 members, 1 guests, 0 anonymous users