0
我有一個數組$ emails。該print_r($emails)
輸出如下:發送郵件給每個數組值
Array
(
[0] => Array
(
[user_email] =>
)
[1] => Array
(
[user_email] => [email protected]
)
[2] => Array
(
[user_email] => [email protected]
)
)
現在我想發送電子郵件到的所有電子郵件地址此陣英寸我想:
foreach($emails as $contact) {
$to = $contact;
$subject = 'the subject';
$message = 'hello';
mail($to, $subject, $message, $headers);
}
我得到的是:Warning: mail() expects parameter 1 to be string, array given
'$接觸[ 'USER_EMAIL']' – AbraCadaver 2014-09-10 15:42:45
你有一個數組的數組。因此該數組中的每個元素都是一個數組。錯誤信息很清楚,'mail()'不指望數組。 – David 2014-09-10 15:43:06
您還應該檢查一個空的電子郵件,就像第一個電子郵件一樣。 – Barmar 2014-09-10 15:43:37