Need to remove all the charachter which start with [quote]any string[/quote]

Discussion in 'PHP' started by Subikar, Nov 16, 2008.

  1. #1
    Hi all need to remove
    in between
    from the string. How I will perform through preg_replace

    I am trying with this but not removong


    
    
    $message = '[b]cozewrote:[/b] [quote][b]cozewrote:[/b] [quote][b]cozewrote:[/b] [quote][b]cozewrote:[/b] [quote][b]cozewrote:[/b] hello[/quote] hello[/quote] testing[/quote] hellotestingagain[/quote] testyourbest'
    preg_replace('/\[quote\](.*?)\[\/quote\]/', '', $message);
    
    PHP:
    Result should be

    'cozewrote:testyourbest

    Regards,
    Subikar
     
    Subikar, Nov 16, 2008 IP
  2. Subikar

    Subikar Active Member

    Messages:
    241
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #2
    No one is there who can answer this question.

    Regards,
    Subikar
     
    Subikar, Nov 17, 2008 IP
  3. xenous

    xenous Peon

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This will do it
    
    <?php
    $message = "Your message";
    $messagewithoutqouotes=cleanQoutes($message);
    function cleanQuotes($message){
    $begin=strstr($message,'[quote]');
    $rest=strstr($begin,'[/quote]');
    $interested=str_replace($rest,"",$begin);
    if(eregi("[quote]",$interested):
    cleanQoutes($interested);
    endif;
    return $interested
    }
    ?>
    PHP:
     
    xenous, Nov 17, 2008 IP