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);