PHP: do not interpret HTML surrounded by DIV

You’re getting those extra line-breaks because highlight_string in PHP returns HTML with line breaks after each line. Running nl2br on this HTML then converts these line breaks to the extra <br /> in your code (note that there are <br /> tags at the beginning of each line.

To combat against this I recommend changing all
<br /> and <br /> to
and then all
back to <br />

return nl2br(preg_replace('/\
?<(br|BR).*?>/', '\
', $return));