ToddAtWSU Posted December 12, 2007 Share Posted December 12, 2007 I am writing a string that I want to send as the message of an e-mail I send out using the mail function. Part of that message is what I call the pickString. I have a loop that makes this string. But at each iteration I want 2 blank lines between it and the next iteration. Unfortunately, it doesn't seem to keep the newlines. My e-mail doesn't show them. Here is a snippet of my code. Thanks! $pickString = ""; for( $i = 0 ; $i < $numGames ; $i++ ) { $visitorString = "visitor" . (string) ( $i + 1 ); $homeString = "home" . (string) ( $i + 1 ); $visitorScore = $_POST[$visitorString]; $homeScore = $_POST[$homeString]; if( empty( $visitorScore ) ) { $visitorScore = 0; } if( empty( $homeScore ) ) { $homeScore = 0; } //$pickString = $pickString . $_POST[$visitorString] . "\n" . $_POST[$homeString] . "\n"; $pickString = $pickString . $visitorScore . "\n" . $homeScore . "\n" . "\n" . "\n"; } Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 12, 2007 Share Posted December 12, 2007 are you trying to create physical html line break or just source code line break? Physical Line Break = <br> or use nl2br Source Code Line Breaks = \n Quote Link to comment Share on other sites More sharing options...
ToddAtWSU Posted December 12, 2007 Author Share Posted December 12, 2007 Source code line break. This is a non-html e-mail being sent. Just text. So I am using 3 '\n' characters but it is only using one of the '\n' characters. I have tried all 3 in the same "" and like my example with 3 individual strings. Thanks again for your assistance. Quote Link to comment Share on other sites More sharing options...
dsaba Posted December 12, 2007 Share Posted December 12, 2007 \n is not the only way to write a linebreak or carriage return unix \n windows \r\n mac \r html <br> My e-mail doesn't show them. You mean your email client? Who knows how your email client interprets line breaks, it may have its own method.. for example in .rtf documents created by microsoft wordpad \par represents a line break try out different things, and find proof how linebreaks are written/represented in whatever you're using to "look at" this email Quote Link to comment Share on other sites More sharing options...
ToddAtWSU Posted December 12, 2007 Author Share Posted December 12, 2007 I went straight to my Gmail account and looked at it through Gmail because I thought Outlook might be removing extra line breaks. But this was not the case. GMail was also not showing the newlines. I will try some of these though. Thanks! Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 12, 2007 Share Posted December 12, 2007 what is the code for sending the email, can you show us that ? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted December 12, 2007 Share Posted December 12, 2007 Are you using single or double quotes to enclose the single line breaks? Double quotes will translate to a new line but single quotes will send the \r exactly as it is - do these appear in the emails where the new lines should be? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.