How to remove <br /> tags and more from a string?

<?php

$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// Allow <p> and <a>
echo strip_tags($text, '<p><a>');

?>

http://php.net/manual/en/function.strip-tags.php


You can use str_replace like this:

  str_replace("<br/>", " ", $orig );

preg_replace etc uses regular expressions and that may not be what you want.


If str_replace() isnt working for you, then something else must be wrong, because

$string = 'A string with <br/> & "double quotes".';
$string = str_replace(array('<br/>', '&', '"'), ' ', $string);
echo $string;

outputs

A string with      double quotes .

Please provide an example of your input string and what you expect it to look like after filtering.