agahi agahi - 8 months ago 25
PHP Question

removing unknown number of tags from inside a tag

I have these string:

$st = '<p><br/></p>';
$st = '<p><br/><br/></p>';
$st = '<p><br/><br/><br/></p>';

How can I remove all the line breaks from inside the P tag?
I tried this but didn't work:

echo preg_replace('/p>(br\/>)*?<\/p/','p></p',$st);

I'm sorry, seem I need to explain. more. This would be inside a larger text and I don't want to remove all the line breaks. Only those which are inside a P tag with unknown number of occurance.


Change your REGEX to: