How about using strip_tags , which should only do the job?
For example (citing a document):
<?php $text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>'; echo strip_tags($text); echo "\n";
will provide you with:
Test paragraph. Other text
Edit: but note that strip_tags does not confirm what you give it. This means that this code:
$text = "this is <10 a test"; var_dump(strip_tags($text));
You'll get:
string 'this is ' (length=8)
(Everything after the thing similar to the original tag is deleted).
source share