Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Location
    Texas
    Posts
    472
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Quote BB code tag

    I have the following to make a quote BB code tag:

    PHP Code:
    $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:

    PHP Code:
    $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?
    If you're reading this, it may already be too late!

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it works when you do multiple iterations of that one line one after another:
    PHP Code:
    $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:
    PHP Code:
    while($messagee != preg_replace($bbfind$bbreplace$messagee)) {
        
    $messagee=preg_replace($bbfind$bbreplace$messagee);


  • #3
    Regular Coder
    Join Date
    Feb 2005
    Location
    Texas
    Posts
    472
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hey, that worked.
    If you're reading this, it may already be too late!

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I love it when a plan comes together


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •