Hi,
How it is possible to allow <br /> in strip_tags() or any way I can get around to it?
<?php
$text = '<p>Test <br />paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\
";
// Allow <p>, <a>, <br />
echo strip_tags($text, '<p><a><br />');
echo "\
";
// Allow <br /> only
echo strip_tags($text, '<br />');
?>
result:
Test paragraph. Other text
<p>Test paragraph.</p> <a href="#fragment">Other text</a>
Test paragraph. Other text
Thanks,
Lau
yes I believe you! thanks
rpkamp
September 25, 2010, 1:54pm
3
If you use <br> as the second parameter for the strip_tags function it’ll leave <br /> in the text untouched. Just the way the function works. Try it if you don’t believe me
system
September 25, 2010, 1:34pm
4
You don’t have <br /> in your result code. Where to you want it?
rpkamp
September 25, 2010, 1:35pm
5
Use <br> instead of <br />
system
September 25, 2010, 1:36pm
6
But maybe he wants it W3C compliant for XHTML?
thank you. I should had thought of that! lol