0

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.

2
Contributors
2
Replies
13
Views
2 Years
Discussion Span
Last Post by Ehsan_4
0

Why don't you push both values (the entire record) to the same array:

while () {
    $recipients[] = $row;
}

foreach ($recipients as $recipient) {
    $mail->AddBCC($recipient['email'], $recipient['full_name']);
}
1

Thank you very much pritaeas, your solution works as well as array combine.

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

foreach($recipients as $email => $full_name)
{
    $mail->AddBCC($email, $full_name);
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.