Jump to content

Newlines


ToddAtWSU

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

\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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.