Ðr Ssamade Ðr Ssamade - 1 year ago 47
PHP Question

Php mail array to string

I need to send an email to users , everyone . and this is the array

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)

and I have this code to send email

$hs = "From: \"Ishharat\"<moi@test.com>\n";
$hs .= "Reply-To: moi@test.com\n";
$hs .= "Content-Type: text/html; charset=\"utf-8\"";

return TRUE;
else {
return FALSE;


Just use a foreach loop;

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