Avatar of 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 undefined
Last Comment

8/22/2022 - Mon

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.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes