Remove all HTML attributes

[SIZE=“3”][FONT=“Arial”]I’m trying to delete almost all HTML attributes from my tags with the exception of some like src=“” or href=“”.

for example this:
<p class=“myclass”><b style=“color:#333;”>Hello</b></p>

To:
<p><b>Hello</b></p>

Is something like that possible with preg_replace?

[/FONT][/SIZE]

Edit: nah, sorry dude :slight_smile:

you can remove elements’ attributes using DOM methods.

Thanks Kalon. I was already looking at DOM methods but I’m not really known with them so that hold me back a bit. I will try them out now.

@eljohnsen well it is possible to exclude things like a class for example
preg_replace(“#class=\”.*?\“#is”, “”, $content);
But instead of making a list of what has to go out I would like to exclude all except
some indicated attributes.

Remove all HTML tags.

striptags($results); // remove <b> etc.

Unfortunately, that is not what the OP is asking for. :wink:

Unfortunately, that is not what the OP is asking for

thanks for replying for me Anthony :slight_smile: