Hamender Hamender - 1 year ago 109
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 Source

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);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download