Php strip_tags: allows <br />?

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! :slight_smile: thanks :slight_smile:

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 :slight_smile:

You don’t have <br /> in your result code. Where to you want it?

Use <br> instead of <br /> :slight_smile:

But maybe he wants it W3C compliant for XHTML?

thank you. I should had thought of that! lol :stuck_out_tongue: