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 开发者_JAVA百科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 "\n".
If you want to reproduce the newlines of your users input in HTML, you have to convert every \n 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\n bar"); ?>The above example will output:
foo isn't<br /> bar
加载中,请稍侯......
精彩评论