Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: New line in php not working Date: Sun, 29 Jan 2017 09:30:05 +0100 Lines: 50 Message-ID: References: <0157ce84-974d-407e-9a25-c66e8ceba904@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net rPkKwG4XfqQOohfR4FBcJw5+V0WOlSX0fBorXlNrCV/qzETBvr Cancel-Lock: sha1:XnWAJN/i68N6QkUS3AcLCJdeVSc= X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: <0157ce84-974d-407e-9a25-c66e8ceba904@googlegroups.com> Xref: csiph.com comp.lang.php:17301 On 01/29/17 03:24, wart2ww wrote: > The following code all works fine in a block except the \n is not working. > All the fields in the in the email are on one line. This has nothing to do with "\n" not working, this is the way the mail client handles the "\n", for example the terrible mail client outlook will show all in one line, you will need to have "\t\n\n" for it to handle this correctly, while the nice Thunderbird will show it as intended as it is with "\n". > I have done this before and it seemed to work but not now. What have I done wrong? > > foreach ($_POST as $key => $value) { > > if (isset($fields[$key])) { > $emailText .= "$fields[$key]: $value\n"; } > } For more readability of your code, you should stick with a coding standard and make variables in a string to stand out foreach ($_POST as $key => $value) { if (isset($fields[$key])) { $emailText .= "${fields[$key]}: ${value}\n"; } } or foreach ($_POST as $key => $value) { if (isset($fields[$key])) { $emailText .= $fields[$key] .": ". $value ."\n"; } } > Thank you for your help. np. -- //Aho