Crazylife's avatar

Explode a string into an array with assigned value and send the email to multiple recipient with recipient name

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?

0 likes
3 replies

Please or to participate in this conversation.