On 01/29/17 03:24, wart2ww wrote:
> The following code all works fine in a <?php ?> 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