在 for 循环之后,我得到一个二维数组值。值是$chunk[$i][$j]
。当我将该值传递给 setTo 函数时,错误显示为
Warning: preg_match() expects parameter 2 to be string, array given in H:\xampp
\htdocs\sngmarket\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\Headers
\MailboxHeader.php line 350
.
我该如何解决?。这是我的代码
$query = $em->createQuery("SELECT DISTINCT u.emailaddress FROM AcmeRegistrationBundle:userlist u");
$grp_emails[] = $query->getResult();
$chunk = array_chunk($grp_emails, 10);
$get_chunk_count = count($chunk);
for($i=0;$i<$get_chunk_count;$i++)
{
$count_inside_count = count($chunk[$i]);
for($j=0;$j<=$count_inside_count;$j++)
{
$mails=$chunk[$i][$j];
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('marketplace@socialnetgate.com')
->setTo($mails)
->setReturnPath('gowtham@ephronsystems.com')
->setBody('Hello World');
$this->get('mailer')->send($message);
return array();
}
}