Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-03-2009, 12:23 AM   PM User | #1
maxvee8
Regular Coder

 
maxvee8's Avatar
 
Join Date: Feb 2008
Location: UK
Posts: 185
Thanks: 19
Thanked 18 Times in 18 Posts
maxvee8 is an unknown quantity at this point
Question How do i include array data in php mail?

Ok ive baffled my self for some reason, as in the title How do i include array data in php mail?

The Code i have:

I have stored post ids in a variable $ids array:

PHP Code:
$ids[]= $row['ID']; 
i have then created a foreach ( i dont actually want to out put this data as it is meant to be included in the mail message)

PHP Code:
foreach ($ids as $expired){
echo 
'<a href="http://www.domain.com?s='.$expired.'">Link Text</a><br />';


and the mail code:
PHP Code:
mail("info@domain.com","email subject","email body","Content-Type: text/html; charset=iso-8859-1\n"); 
So how do i list the contents of the array $ids[] in the mail message / email body i might be over thinking something!? any help is apreciated.
__________________
"I have not failed, I've found 10,000 ways that don't work" Thomas Edison
maxvee8 is offline   Reply With Quote
Old 09-03-2009, 01:31 AM   PM User | #2
kbluhm
Senior Coder

 
kbluhm's Avatar
 
Join Date: Apr 2007
Location: Philadelphia, PA, USA
Posts: 1,503
Thanks: 2
Thanked 258 Times in 254 Posts
kbluhm will become famous soon enough
PHP Code:
foreach ( $ids as $i => $expired )
{
    
$ids[$i] = '<a href="http://www.domain.com?s=' $expired '">Link Text</a>';
}

$ids implode"\n"$ids );

mail(
    
"info@domain.com",
    
"email subject",
    
nl2br"email body\n\nExpired IDs:\n{$ids}" ),
    
"Content-Type: text/html; charset=iso-8859-1\n"
); 
__________________
ZCE

Last edited by kbluhm; 09-03-2009 at 01:35 AM..
kbluhm is offline   Reply With Quote
Users who have thanked kbluhm for this post:
maxvee8 (09-03-2009)
Old 09-03-2009, 01:33 AM   PM User | #3
Scriptet
Regular Coder

 
Join Date: Apr 2008
Posts: 685
Thanks: 15
Thanked 105 Times in 104 Posts
Scriptet is on a distinguished road
Can't you just assign the data to a variable then include it in the message like:

PHP Code:
foreach ($ids as $expired){
$message .= '<a href="http://www.domain.com?s='.$expired.'">Link Text</a><br />';

then send $message in replace of "email body"?
Scriptet is offline   Reply With Quote
Old 09-03-2009, 02:09 AM   PM User | #4
maxvee8
Regular Coder

 
maxvee8's Avatar
 
Join Date: Feb 2008
Location: UK
Posts: 185
Thanks: 19
Thanked 18 Times in 18 Posts
maxvee8 is an unknown quantity at this point
Wow awesome just tested your code and it works just as it should.

i thought there had to be a way to extract the info from the array! and ive learnt something new too , not bad haha, thanks @kbluhm
__________________
"I have not failed, I've found 10,000 ways that don't work" Thomas Edison

Last edited by maxvee8; 09-03-2009 at 02:17 AM..
maxvee8 is offline   Reply With Quote
Reply

Bookmarks

Tags
php mail

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:42 AM.


Advertisement
Log in to turn off these ads.