// How can I add “foreach” loop’s output to $message
$message .=
In principle:
$array = array('this', 'that', 'the', 'other');
$msg = "" ; // message is an empty string to start with, say.
$msg .= "Today my talk is about: "; // no space between .= !!
foreach( $array as $element ){
$msg .= $element . " "; // add a space between each word
}
echo $msg . ". Thank you.";
// Today my talk is about: this that the other . Thank you.
There are other ways of adding array elements to a string, but to answer your question this ought to illustrate.
ps this line
$message .= $msg\
";
should be
$message .= $msg . "\
";
And if a line end is what you want you could do this:
$message .= $msg . PHP_EOL; // php end of line
// An OS specific line end
thank you so mush Cups for your valuable suggestions. Sorry for being late, I was out of town. Now I have changed my script according to your guidelines. Everything is working perfectly except two things. I wana send automatic email notifications to Admin on my forums. Whenever a new thread is started Admin get email. Now I am trying to add recent x number topic to email message.
Initially variable $newposts was declared. I changed it to $_SESSION[‘new_posts’] because $newposts was not being passed to posttomail.php file. Any Idea ?