I have a textarea where an user can use both BBCode and HTML code in order to insert news in database. When I want to show this news in site, PHP script convert BBCode to HTML entities and convert news content (get from database) in HTML standard preserving HTML tags. The problem is when I want to convert newline to <br />
tag with nl2br() function, because <br />
is added after HTML tags too, for example:
<li>Some text</li><br />
or
<table><br />
<tr><br />
etc.
Is there a way to avoid this annoying problem?