我有这个PHP代码:

while($contacts2=mysql_fetch_array($rs))
    {
        //generate the list of emails address in an array
        $emails_list[] = $contacts2["email"];
    }


所以它把我所有的结果放入一个数组,但是当我在while循环外回显$emails_list时,它只显示Array

我如何使其显示为:

result1,result2,result3

最佳答案

这是你的答案

while($contacts2=mysql_fetch_array($rs))
{
     //generate the list of emails address in an array
     $emails_list[] = $contacts2["email"];
}

$emails_list = implode(',', $emails_list);
echo "(". $emails_list . ")";


我想你应该这样

$mail->AddAddress('[email protected]', 'Person One');
$mail->AddAddress('[email protected]', 'Person Two');


使用PHPMailer,您可以执行以下操作:

while($contacts2=mysql_fetch_array($rs))
{
    $mail->AddAddress($contacts2['emails'], $contacts2['name']);
}

10-05 20:04