html5 - PHP getting enter from textarea to send email -
i created form users key in recipient, subject name, , message send mail via phpmailer. problem i'm facing textarea in form.
i typed textarea:
hi john, how's day? regards, best friend
but right now, showing in email:
hi john, how's day? regards, best friend
any ideas on how format how user enters in text area? current script just
$body= $_post["msg"];
i read should use nl2br isnt output? in advance
what need add break each line.
$text = trim($_post['textareaname']); // remove last \n or whitespace character $text = nl2br($text); // insert <br /> before \n
if dont try this:(you may need play it.)
//trim off excess whitespace off whole $text = trim($_post['textareaname']); //explode separate lines array $textar = explode("\n", $text); //trim lines contained in array. $textar = array_filter($textar, 'trim'); $str=''; //loop through lines foreach($textar $line){ $str .= $line."</br> "; }
Comments
Post a Comment