如何允许< br />在strip_tags()或任何我可以解决它的方式?
<?PHP $text = '<p>Test <br />paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>'; echo strip_tags($text); echo "\n"; // Allow <p>,<a>,<br /> echo strip_tags($text,'<p><a><br />'); echo "\n"; // Allow <br /> only echo strip_tags($text,'<br />'); ?>
结果:
Test paragraph. Other text <p>Test paragraph.</p> <a href="#fragment">Other text</a> Test paragraph. Other text
谢谢,
刘