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
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: