Capture Newline From A Textarea Input
I have a textarea form in my html. If the user hits enter between 2 sentences that data should be carried over to my PHP. Currently if the user enters: Apple Google MS and my PHP
Solution 1:
Try nl2br()
instead:
echo nl2br($str);
Solution 2:
The newlines should be included in the string that you get from $_POST["field"]
. However, if you then use that string as output in HTML, newlines will be treated as whitespace. To force the line breaks, use preg_replace("/\n/", "<br />", $str)
.
Post a Comment for "Capture Newline From A Textarea Input"