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
2010-03-24 12:20:25
...very very badly indeed!
Elister
2010-03-24 12:37:09
A:
Can you provide an example of a string you are having a problem with?
Stephen
2010-03-24 12:29:38
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
2010-03-24 12:34:50
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
2010-03-25 02:17:33
@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
2010-03-25 09:17:24