Search code examples
phptextarealine-breaks

Make a line break in a value of textarea in PHP


So here's an example of a value inside a textarea.

Welcome to my site

Blah blah blah?

And when echo the value it goes like this:

Welcome to my site Blah blah blah?

How can line break it without typing... \n or < br > using PHP

Or for a good example. Like we have here in Stack Overflow when you ask a question.


Solution

  • Convert linebreaks to <br /> with nl2br().