Reputation: 397
I have an array $emails. The print_r($emails)
output following:
Array
(
[0] => Array
(
[user_email] =>
)
[1] => Array
(
[user_email] => [email protected]
)
[2] => Array
(
[user_email] => [email protected]
)
)
Now I want to send emails to all email addresses in this array. I tried:
foreach($emails as $contact) {
$to = $contact;
$subject = 'the subject';
$message = 'hello';
mail($to, $subject, $message, $headers);
}
What I get is: Warning: mail() expects parameter 1 to be string, array given
Upvotes: 0
Views: 628
Reputation: 1963
foreach($emails as $contact) {
$to = $contact['user_email'];
$subject = 'the subject';
$message = 'hello';
mail($to, $subject, $message, $headers);
}
Upvotes: 1