Page 1 of 1

php mail and arrays

Posted: Fri Oct 30, 2009 1:27 pm
by dimxasnewfrozen
I have a simple submit form with a few check boxes. I'm storing the results of what's being checked into an Array.

How can I use the mail function to send the results of the array?

Just for a small example, I have:

Code: Select all

 
$mailcontent=
    foreach ($location as $loc)
    {
         echo $loc . "<br/>";
    } .  " Thank you!" ; 
 
mail($toaddress,$subject, $mailcontent);
 
I don't want the array printed of course, but I want the results of the array in the main mail message.

Re: php mail and arrays

Posted: Fri Oct 30, 2009 1:46 pm
by jackpf
I think you want implode().

Re: php mail and arrays

Posted: Fri Oct 30, 2009 1:54 pm
by dimxasnewfrozen
That's exactly what I needed. Thank you!

Now, how do I break a line for each one?

I tried implode('\n', $locations);
I also tried implode("<br>" ,$locations);

which just prints out \n and <br>...

Re: php mail and arrays

Posted: Fri Oct 30, 2009 6:15 pm
by jackpf
Try "\n" instead of '\n'. Notice double quotes.