Page 1 of 1

Removing tags

Posted: Sun Jun 01, 2008 5:32 pm
by fluidbyte
I'm new to php and I'm working on an inline content manager. I've got a WYSIWYG editor, but when I pass it through (post) I'm wanting to remove any link tags (<link href="whatever.css" />) as well as any <style>[CONTENTS]</style> tags.

I know regular expressions is probably the way to go, but I can't seem to get it figured out. Any help would be greatly appreciated.

Re: Removing tags

Posted: Sun Jun 01, 2008 5:42 pm
by Benjamin
Do you need all tags removed or only specific tags?

strip_tags may work for you: http://us3.php.net/manual/en/function.strip-tags.php

Otherwise you may want to take a look at htmlpurifier: http://htmlpurifier.org/

I've never used that so I don't know if it will work for you but I do believe you can pass it a list of approved tags.

Your next option is to parse them out with regex.

Re: Removing tags

Posted: Sun Jun 01, 2008 5:52 pm
by fluidbyte
I want to let the user apply almost any onther tags (including in-line styles). I just don't want them to be able to attach a stylesheet, or create an internal ss.