Array problem?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
freddylocks
Forum Newbie
Posts: 7
Joined: Tue Oct 18, 2005 10:18 am

Array problem?

Post by freddylocks »

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi Everyone

I wonder if someone could help me out with a little problem i am having with a array...
I am using Manuel Lemos's pop3 access script, it works very well and is about to retreive the messages fine without any issue. http://www.phpclasses.org/browse/package/2.html

However in the same php script file i am trying to send a email (essentially download an email, attach a document and forward a email on automatically). I am using phpMailer for this.

I am able to do the 2 individual parts, however I am having a problem merging the incoming mail, with the outgoing mail. The download part works, and the send email with appropriate attachement works. However the issue i am having surrounds getting the data out of the array... here is the details

Code: Select all

for($line=0;$line<count($body);$line++)
	echo "<PRE>",HtmlSpecialChars($body[$line]),"</PRE>\n";
These 2 lines display the email on a page in the correct format.
I them want to take the body (which is about 15lines long (size varies!)) and insert it into another email...

I currently have this which doesn't work...

Code: Select all

$mail->Body = "hello";
	for($line=0;$line<count($body);$line++){
	$mail->Body .= "".$body[$line]."\n";
	}
I have tried using this... which makes the formatting come out incorrectly...

Code: Select all

$body1=implode("\n", $body);
	$mail->Body = $body1;
Any pointers that anyone has in helping me get the data out of the array called $body would be very much appreciated.

Thanks
Freddy


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
freddylocks
Forum Newbie
Posts: 7
Joined: Tue Oct 18, 2005 10:18 am

Answer

Post by freddylocks »

Ok i managed to sort it out...

The following code does actually work.

Code: Select all

$mail->Body = "hello"; 
    for($line=0;$line<count($body);$line++){ 
    $mail->Body .= "".$body[$line]."\n"; 
    }
cheers
Freddy
Post Reply