Echo respecting mysql line break

1

I would like to know how to make PHP echo respect the line break of a text in the database.

I have a text field in the registration form like this:

<textarea id="descricao" name="descricao" class="input form-control col-lg-10" rows="5" required></textarea>

In the database it looks like this:

Iwouldlikeatthetimeofecho<?phpecho$row['descricao'];?>,thesameBDlinebreaktoberespectedinthedisplay.

Butit'sallappearingonasingleline:

    
asked by anonymous 09.08.2017 / 19:45

1 answer

3

Try to use the nl2br ()

PHP Documentation:

  

nl2br - Inserts HTML line breaks before all newlines in one   string

Changes to the following:

<?php echo nl2br($row['descricao']); ?>
    
09.08.2017 / 19:50