1

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

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) 

and I have this code to send email

$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;
 }
1
  • create email method and use it in loop on array Commented Apr 29, 2016 at 16:34

1 Answer 1

1

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
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you sir , It's working but I have used $user["email"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.