Basically i'm trying to set something where a user enters some text into a textarea (and they press their enter key to add new lines) and then it takes the value from that text area and mails it out in the message of a new email to a specified contact.
All the mailing functionality works, but I need to be able to automatically add a new line when the user presses enter in the textarea.
Using this to get the info from the previous page/form and replace the \\r\\n:
$BREAKINGNEWS=$_POST['BREAKINGNEWS'];
$NEWS = str_replace("\r\n","<br />",$BREAKINGNEWS);
Then just adding $NEWS into the code to mail it out.
Doesn't seem to work though, just puts it on 1 line and doesn't replace the \\r\\n!
Any help is most appreciated :)
只需使用内置的nl2br
nl2br really works.
PHP内置了nl2br函数,它完全符合您的要求。
Try to use nl2br. It will respect all different formats like \\n, \\r or \\r\\n (http://de.php.net/manual/en/function.nl2br.php)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.