Hello, This code seems to remove almost everything between the <p> and </p> tag but not inner tags within the p-tags. A lesser problem is that it does not remove the <p> tags themselves. $output = preg_replace('#(<p[^>]*>).*?(</p>)#', '$1$2', $output) Code (markup): I need a snippet of code that will remove everything including the <p>,</p> tags and also remove all inner tags.
Scripts_man, I ran across striptag as I was googling: http://php.net/manual/en/function.strip-tags.php If I understand correctly, I have to specify every possible tag I would want to keep,,, not the one I want to get rid of. This is directly from the page: // Allow <p> and <a> echo strip_tags($text, '<p><a>'); PHP: The above example will output: <p>Test paragraph.</p> <a href="#fragment">Other text</a>
This does what you have asked for above. <?php $str = '<p> hello <b>world</b></p><br />this is a test'; $f=preg_replace("/<p>(.*)<\/p>/", "", $str); print $f; ?> PHP: OUTPUT: <br />this is a test
Your old code: $output = preg_replace('#(<p[^>]*>).*?(</p>)#', '$1$2', $output) Code (markup): You need to backslash closing tags : like <\/p> Try this, it should remove everything between and including the p tags replacing with your $1$2 variables $output = preg_replace('#<p[^>]*>(.*)<\/p>#', '$1$2', $output); Code (markup):
Sorry! I just saw the first post and clicked the Reply with Quote Directly!! I urge i always doing this type of mistakes Post Removed!