2016-04-29 22 views
2

我需要發送電子郵件給用戶,每個人。這是數組PHP郵件數組到字符串

array(5) { 
    [0]=> array(2) { ["email"]=> string(20) "[email protected]" ["name"]=> string(8) "حمزة" } 
    [1]=> array(2) { ["email"]=> string(13) "[email protected]" ["name"]=> string(4) "tooo" } 
    [2]=> array(2) { ["email"]=> string(14) "[email protected]" ["name"]=> string(8) "احمد" } 
    [3]=> array(2) { ["email"]=> string(21) "[email protected]" ["name"]=> string(14) "اشهارات" } 
    [4]=> array(2) { ["email"]=> string(20) "[email protected]" ["name"]=> string(9) 

,我有這樣的代碼來發送電子郵件

$hs = "From: \"Ishharat\"<[email protected]>\n"; 
$hs .= "Reply-To: [email protected]\n"; 
$hs .= "Content-Type: text/html; charset=\"utf-8\""; 

if(mail($to,$subject,$body,$hs)) 
    return TRUE; 
else { 
    return FALSE; 
} 
+0

創建電子郵件的方法,並用它在環上的陣列 – Ehsan

回答

1

只需使用一個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 
} 
+1

謝謝主席先生,這是工作,但我已經使用$用戶[「電子郵件」] –