I was just wondering if any one knew a function to remove ALL classes from a string in php.. Basically I only want
<p>
tags rather than
<p class="...">
If that makes sense :)
A fairly naive regex will probably work for you
$html=preg_replace('/class=".*?"/', '', $html);
I say naive because it would fail if your body text happened to contain class="something" for some reason!. It could be made a little more robust by looking for class="" inside angled bracketted tags if need be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With