views:

53

answers:

3

strip_tags only catches tags that have a beginning and end tag. With the strings I'm working with it's causing issues and I need to removed all HTML tags.

+3  A: 

If you want to clean some HTML, I would suggest using a real HTML parser, like HTMLPurifier.

Generally speaking, trying to manipulate HTML with regex tends to end badly...

Pascal MARTIN
...very very badly indeed!
Elister
A: 

Can you provide an example of a string you are having a problem with?

Stephen
This should be a comment.
Jens
Tell me about it, but I can only comment on my own answers.
Stephen
A: 
<?php

$html = '<p>Lorem ipsum dolor <br>sit amet, <br />consectetur adipisicing elit</p>';
echo strip_tags($html);

?>

... prints:

Lorem ipsum dolor sit amet, consectetur adipisicing elit

Álvaro G. Vicario
http://www.starcraft-source.com/strategy/article/view/?id=205Look at Micro in the first paragraph you can mouseover it and see the definition you can see paragraph tags that exist within the definition.
Webnet
@Webnet: That proves nothing if you don't show us the original string. If you run strip_tags() on the current contents of the title attribute, tags do get removed.
Álvaro G. Vicario