简体   繁体   中英

Can't get recipient list correctly output for PHPMailer BCC email and full name

how to merge or join or map two arrays fetched from mysql db array full_name and array email to create one recipient list to be bcc for php mailer and then be able to use something like:

$email= array();
$full_name= array();

while loop starts
array_push($email, $row['email']);
array_push($full_name, $row['full_name']);
loop ends

At the end of the while loop i want to merge or join two arrays as shown above how can I do that? can anybody kindly guide me in the right direction?

foreach($recipients as $email => $full_name)
{
   $mail->AddBCC($email, $full_name);
}

Many thanks for your valuable help and advice.

To combine two matching indexed arrays into one associative array (that you can loop over with foreach ), you need to use array_combine . For your code that would be:

$recipients = array_combine($email, $full_name);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM