Link to home
Start Free TrialLog in
Avatar of innercproductions
innercproductions

asked on

Strip tags - except bold, italics, underline, links, and images

I want to take out the HTML that is inputted into a form...
unless it is a simple HTML tag like: <b><i><u><img><a href...

The form submits the info to the database.
Then it will be retrieved again for editting in forms...
And also be displayed on a webpage.



I was looking at all the infor at http://php.net/strip_tags
but it's a little overwhelming.

The closest one I found was the comment dated October 15 2003.

But I couldn't tell if it was what I really needed.

Could someone give me as simple of a script that I could input that would do the job?
A function would be ok too. Maybe better...


Avatar of innercproductions
innercproductions

ASKER

I wanted to add something.

I know that some stripped of tags can cut some of the whitespace as well.

This needs to be noted. And resolved.
ASKER CERTIFIED SOLUTION
Avatar of TeRReF
TeRReF
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh, you only have to enter the opening tags as the second parameter. It will take care of the closing tags (</b>, </i>, etc) on its own... And use the actual tag, none of the attributes. So, <a> instead of <a href> since href is an attribute of a.