Reputation: 13224
It's seems quite simple - strip_tags($string);
But I will repeat - html tags
With use of strip tags for example
"THIS<THISTHISTHIS" >> THIS
Or
$str = "You can write 'more' as < sign" >> "You can write 'more' as "
or
strip_tags("you know that 5<8"); //cuts '8'
and I dont want it.
I know that basicly <everything>
can be tag in html, but I want to remove those default html tags
Upvotes: 1
Views: 97
Reputation: 674
Check HTMLPurifier: http://htmlpurifier.org/
A bit hard in customization, but it gives very good filtering of html and css.
Upvotes: 0
Reputation: 76636
You can use strip_tags()
with a whitelist:
strip_tags($str,'<code><em><p>');
Alternatively, you could use an HTML parser like this one for removing the HTML tags.
Hope this helps!
Upvotes: 1
Reputation: 13535
So why don't use put the tags you want to keep in a string and call strip_tags
$keep = '<a><div><span>';
$new_html = strip_tags($html, $keep);
Upvotes: 1
Reputation: 4616
You could specify which tags you will allow in the second argument of strip_tags:
string strip_tags ( string $str [, string $allowable_tags ] )
Upvotes: 0