Jump to content

Recommended Posts

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";
      }

Link to comment
https://forums.phpfreaks.com/topic/81276-newlines/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/81276-newlines/#findComment-412524
Share on other sites

\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

Link to comment
https://forums.phpfreaks.com/topic/81276-newlines/#findComment-412629
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.