Level 70
You may try this-
$a = array('[email protected]'=>'abc','[email protected]'=>'cde');
foreach($a as $key => $value){
mail->to($key, $value);
}
Ref: http://php.net/manual/en/control-structures.foreach.php
2 likes
I have a string declared as shown below
var email = '[email protected],[email protected]'
I am using explode to make it as an array
$emails = explode(",", $user->email);
With the $emails output like
array:2 [▼
0 => "[email protected]"
1 => "[email protected]"
]
What i am expected is
$a = array('[email protected]'=>'abc','[email protected]'=>'cde');
Result:
array:2 [▼
"[email protected]"=> "abc"
"[email protected]"=> "cde"
]
I want to send email to multiple recipient with the name of recipient.e.g
abc([email protected]);cde([email protected])
It works fine when mail->to a single recipient
mail->to('[email protected]','abc');
Can anyone tell me how can i make it to send an email to multiple recipient with name as well?
You may try this-
$allEmails = '[email protected], [email protected], [email protected]';
$emails = explode(',', $allEmails);
$values = array('abc', 'cde', 'fgh');
array_combine($email, $values);
//output will be
/*
array:3 [▼
"[email protected]"=> "abc"
"[email protected]"=> "cde",
"[email protected]"=> "fgh",
]
*/
Please or to participate in this conversation.