Php strip_tags not working

Hi guys,

strip_tags($myvar)

or

strip_tags($myvar, <p>)

will not strip the <p> tags from my string. I have read a lot of different posts but I’m not sure I trust the sources so I thought I’d ask on here as this is where I get the most sense.

So firstly, why doesn’t it always work?

The string in question is “<p> T-Mobile* *18 *600 *unlimited *500Mb</p>”

Can anyone spot the problem?

Also if it doesn’t work does anyone have a function solution which is short and streamlined.

thanks :wink:

Are you sure that that is the string? It’s not <p> T-Mobile* *18 *600 *unlimited *500Mb</p>

Look at the source of the webpage when you debug stuff like this, not at the webpage itself; it may trick you.

Hi Scalliio, thanks for your reply :slight_smile:
The problem is that this string is entered from a js based text editor plugin so I am not sure is being generated. I will have a look at the db.

So you’re saying that strip_tags would ignore that because it isn’t wrapped in <> or </>?

Which method would I use instead?

You would first use html_entity_decode (whoever came up with that function name… :rolleyes:) so they become “legit” <p> and </p> and then you can apply strip_slashes :slight_smile:

Thanks so much for clearing that up for me, I am no stranger to php and yet it is only now that I seem to be learning some of the specifics that make it such powerful scripting language.

I must stop brushing these things under the carpet and telling myself, “its ok you know C and C++ so you pretty much know php” cos I clearly don’t know it properly LOL

Thanks dude Have a good nite :wink:

No problem. And a good night to you as well :slight_smile: