Is there a way in which you could produce arrays for each of them, so that it only requires one preg_replace? I'm not asking you specifically to do it, but is there a way? :)
Printable View
Is there a way in which you could produce arrays for each of them, so that it only requires one preg_replace? I'm not asking you specifically to do it, but is there a way? :)
@excellent do this:
EDIT: simon beat me :(PHP Code:$whatever = "[b] bold [/b] [i] italics [/i]";
echo bbcode($whatever);
Ah thankyou :) I know this may sound dumb, but how do you know where to use slashes and all that with the bbcode bit(/\[b\]) etc? Cheers
If the character is used in reg ex, then you need to escape it.
this worked for me when changing font, size or color using BB:
PHP Code:$string = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","<font face=$1>$2</font>",$string);
$string = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])","<font color=$1>$2</font>",$string);
$string = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])","<font size=$1>$2</font>",$string);