I am trying to add bbcode type of markup to my forum...it's been pretty easy just piling preg_replace() statement one after another looking for , [ etc...but it seems that code would be slow and nasty...I want to make a single array of statements for this...would something like
$bbcode=array(
array('/\[quote\]/','/\[\/quote\]/')=>array('<b>Quote:<br /><i>','</i></b>'),
array('/\[sarcasm\]/','/\[\/sarcasm\]/')=>array('<b>Please Note Sarcasm:<br /><i>','</i></b>'),
array('/\[b\]/','/\[\/b\]/')=>array('<b>','</b>'),
array('/\[i\]/','/\[\/i\]/')=>array('<i>','</i>'),
"/\[(size=+[1-7]{1})\](.*[^\[]+)\[\/size\]/is"=>"<font \\1>\\2</font>"
);
$body=preg_replace(array_keys($bbcode),array_values($bbcode),$body);
return $body;
be any lighter or quicker, or, does anyone have better suggestions to do this type of thing?
This specific code doesn't seem to work right, but I believe it gets the poitn across of what I am attempting to do...