$content = preg_replace('/<br\s?\/?>/', ' ', $content);
echo html_entity_decode($content);
If you want <br>
converted to a space, and then all HTML displayed with their entities.
If I misinterpreted your question, and you don't want the HTML displayed with their equivalent entities, just skip the html_entity_decode()
function.
Update
Your comment to your OP now says you want the <br>
to be a line break, so simply switch that second argument of preg_replace()
from ' '
to "\n"
.
Update Again
Oh wait, I think I know what you want now. You want all tags to appear encoded, but the <br>
to actually be a line break (i.e. not encoded)? Well if you do switch your <br>
for \n
, and you have no other line breaks, you could throw a quick and dirty nl2br()
on the final markup.
Update
Okay, just do this to get your encoded <br>
back to a literal <br>
.
echo str_replace('<br>', '<br>', $content);