ThoHua ThoHua - 1 month ago 6
HTML Question

Stuck with strip_tags why not working in my code?

I want to remove quotes and html tags from following string:

$mystring='Example string "I want to remove any html tags ABC<sub>DE</sub> from <p>similar</p> types of string?"';


I am using following scripts to remove it but it's doesn't work for me:

echo strip_tags(htmlentities($mystring,ENT_QUOTES));


I want to following output for above string:

Example string "I want to remove any html tags ABCDE from similar types of string?"


Why strip is not working?What I mess here?

Answer

At first use strip_tags function if you want remove html tags then use htmlentities as follow it should be work:

echo htmlentities(strip_tags($mystring),ENT_QUOTES);