Re: extra breaks in sent out emails
| From: | Ben Ramsey | Date: | Sun, 07 Mar 2004 23:40:22 +0000 |
| Subject: | Re: extra breaks in sent out emails | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-179706@lists.php.net to get a copy of this message | ||
I cannot believe that the server converts \r's to \n's. \n does not count as two breaks, either. \r stands for carriage return and \n stands for newline. Even if they are placed side-by-side (e.g. "\r\n"), they should only count as one line. Unless I knew more about your code or your application, I could not determine what was causing the double line break.
Scott Taylor wrote:
Thank you Ben. Using either str_replace("\n", "", $string); or str_replace("\r", "", $string); solves the problem. My guess is that when I submit the data there is both the \r and the \n in there (for there showed 2 white space characters in between the broken text lines). My guess is that the server converts all \r's into \n's, and for this reason when a piece of mail goes out it has two breaks instead of one. Best Regards, and thank you for the help, Scott Taylor Ben Ramsey wrote:-- Regards, Ben Ramsey http://benramsey.com http://www.phpcommunity.org/wiki/People/BenRamseyScott Taylor wrote:What I really don't understand is why there are any line breaks at all, because the trim is supposed to take out all \r & \n 's. Is there another type of line break?trim() actually only strips whitespace (including \r and \n) from the beginning and ending of strings. See http://www.php.net/trim for more information. If you want to completely remove line breaks from your string, use str_replace() to do something like: str_replace("\n", "", $string); and str_replace("\r", "", $string); See http://www.php.net/str-replace Finally, have you tried echoing $body just before the message is sent so that you can see exactly what is being sent to the mail() function?