...

View Full Version : Quote BB code tag



Digger3000
06-24-2005, 08:03 AM
I have the following to make a quote BB code tag:


$bbfind=array("'\[quote date=(.*?) author=(.*?)\](.*?)\[/quote\]'is");

$bbreplace=array("<table border=1><tr><td><font>On $1, $2 said:</td></tr><tr><td><font>$3</td></tr></table>");

$messagee=preg_replace($bbfind, $bbreplace, $messagee);

And that works fine. But if I have a quote tag within a quote tag, it only works once. Currently I have this:


$messagee=preg_replace($bbfind, $bbreplace, $messagee);
$messagee=preg_replace($bbfind, $bbreplace, $messagee);
$messagee=preg_replace($bbfind, $bbreplace, $messagee);

Which allows for 3 quotes. But I'd like to have it be able to have an infinite amount of quotes within quotes (some people might just be crazy enough to do that) without preg_replacing it over and over. Any way to do this?

delinear
06-24-2005, 02:03 PM
If it works when you do multiple iterations of that one line one after another:


$messagee=preg_replace($bbfind, $bbreplace, $messagee);
$messagee=preg_replace($bbfind, $bbreplace, $messagee);
//etc...

Then you should be able to use that as the basis for a loop that will keep running until it stops finding quotes. Try something like:

while($messagee != preg_replace($bbfind, $bbreplace, $messagee)) {
$messagee=preg_replace($bbfind, $bbreplace, $messagee);
}

Digger3000
06-24-2005, 02:34 PM
Hey, that worked. :thumbsup:

delinear
06-24-2005, 03:08 PM
I love it when a plan comes together :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum