Hamender Hamender - 4 months ago 24
PHP Question

remove p tag having br tag in php

I am inserting data in database using ckeditor in php but when I press enter then it generates empty p tag with multiple attributes & br tags having id attributes like that


<p style="text-align:center" id="mf147"><br id="mf148"></p>



how can i remove it ? Please give me solution

Answer

I have try this one for removing the tags you required, please check is it working for you preg_replace('#<p\sstyle=".*?"\sid=".*?">(<br\sid=".*?" ?>)</?p>+#','',$string);