"\ n" be converted to "br" automatically

3

I'm developing a PHP post system with MySQL. I need the line breaks that the user enter in textarea to be converted to <br /> .

The variable $texto (contains the contents of the post) goes to the database in the column conteudo (type TEXT).

When the user breaks the line in textarea , a space is automatically added. I needed to replace this space with a <br /> .

    
asked by anonymous 15.10.2016 / 19:11

1 answer

2

nl2br

(PHP 4, PHP 5, PHP 7) - Inserts HTML line breaks before all newlines into a string

Description

string nl2br ( string $string )

Returns string with <br /> inserted before all newlines.

    
15.10.2016 / 19:19