# PHP: do not interpret HTML surrounded by DIV

**URL:** <https://forum.kirupa.com/t/php-do-not-interpret-html-surrounded-by-div/262771>\
**Category:** programming\
**Created:** [June 9, 2008, 7:07pm UTC](https://forum.kirupa.com/t/php-do-not-interpret-html-surrounded-by-div/262771 "2008-06-09T19:07:02Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![icio](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/icio/32/484_2.png) [@icio](https://forum.kirupa.com/u/icio)\
**Post date:** [June 10, 2008, 10:02pm UTC](https://forum.kirupa.com/t/php-do-not-interpret-html-surrounded-by-div/262771/21 "2008-06-10T22:02:18Z")

</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 /\>

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

```

[Previous page](https://forum.kirupa.com/t/php-do-not-interpret-html-surrounded-by-div/262771.md?page=1)
