Php邮件数组到字符串


Php mail array to string

我需要给每个用户发送一封电子邮件。这是阵列

array(5) { 
    [0]=> array(2) { ["email"]=> string(20) "test@outlook.fr" ["name"]=> string(8) "حمزة" } 
    [1]=> array(2) { ["email"]=> string(13) "test@yahoo.com" ["name"]=> string(4) "tooo" } 
    [2]=> array(2) { ["email"]=> string(14) "test@inbox.ru" ["name"]=> string(8) "احمد" } 
    [3]=> array(2) { ["email"]=> string(21) "test@gmail.com" ["name"]=> string(14) "اشهارات" } 
    [4]=> array(2) { ["email"]=> string(20) "test@yahoo.com" ["name"]=> string(9) 

我有这个代码发送电子邮件

$hs = "From: '"Ishharat'"<moi@test.com>'n";
$hs .= "Reply-To: moi@test.com'n";
$hs .= "Content-Type: text/html; charset='"utf-8'"";
 if(mail($to,$subject,$body,$hs))
   return TRUE;
 else {
   return FALSE;
 }

只需使用foreach循环;

foreach ($users as $user) {
  $user->email; // the email to use in the mail() function
  $user->name; // The name to use in the headers of the mail() function
}