From: Richard Quadling on
On 13 July 2010 15:46, Joey Hendricks <j.hendricksjr(a)comcast.net> wrote:
> Hi Mr. Quadling,
>  Thank you for the reply. I still don't understand how to get all the emails
> into the function. Before I put in the function I had something like this-
> for($i=0; $i<=9; $i++)
> {
> if(!empty($_GET[email.$i]))
> {
> mail($_GET[email.$i], $email_subject, $email_message, "From: ".$from);
> }
>  }
> But then I made this function-
> function mail_message($data_array, $template_file, $deadline_str)
> {
> $email_message = file_get_contents($template_file);
> $email_message = str_replace("#DEADLINE#", $deadline_str, $email_message);
> $email_message = str_replace("#DATE#", date("F d, Y h:i a"),
> $email_message);
> $email_message = str_replace("#NAME#", $data_array['name'], $email_message);
> //This to variable is where I get the error
> $to=$mymail;
> $from='j.hendricksjr(a)comcast.net';
> $email_subject='Bubs Birthday';
>  mail($to, $email_subject, $email_message, "From: ".$from);
>  }
> And this is where I call the function-
> if(!empty($_GET[email.$i]))
> {
> mail_message($_GET[email.$i], "email_template.txt", $deadline_str);
> }
> Thank you very very much for your help.
> Joey.

Try ...

$to = '';
foreach(range(1,9) as $i) {
$to .= (!!$to ? ',', : '') . $_GET["email{$i}"];
}