如何用PHP格式从textarea中读取换行符?

How can I read the New-line so that when users fill in a text-area inside my form, and then hit submit, the text is displayed exactly the same way as they wrote it?

I should mention I read in the variables from the form with POST method in my php file.

Thanks

The newline character in PHP is presented by the string " ".

If you want to reproduce the newlines of your users input in HTML, you have to convert every to a <br />. You could do that by hand or use the function nl2br in such a way:

echo nl2br($_POST['input']);

Take a look at the nl2br function.

Example from documentation:

<?php echo nl2br("foo isn't
 bar"); ?>

The above example will output:

foo isn't<br /> bar