php数组和mysql语法错误
我正在尝试使用SwiftMailer将电子邮件地址提取到php数组和mysql语法错误,php,mysql,arrays,Php,Mysql,Arrays,我正在尝试使用SwiftMailer将电子邮件地址提取到数组()我有一个原始示例,我知道我想在其中添加什么,但从树上看不到森林。。。任何一个眼睛正常的人请: // Send the message $result = $mailer->send($message); // Send the message $failedRecipients = array(); $numSent = 0; 这就是我挣扎的地方: foreach($groups as $value) {
数组()
我有一个原始示例,我知道我想在其中添加什么,但从树上看不到森林。。。任何一个眼睛正常的人请:
// Send the message
$result = $mailer->send($message);
// Send the message
$failedRecipients = array();
$numSent = 0;
这就是我挣扎的地方:
foreach($groups as $value)
{
echo "<h3>".$value."</h3>"; //this is working
// get the email groups
$sql="SELECT * FROM emails WHERE sendesstat=1 AND deleted=0 AND classhoz=\"".$value."\"";
$query=mysql_query($sql);
// fetch the emails from the group
while($data=mysql_fetch_array($query))
{
$emil="'".$data["email"]."' => '".$data["firstname"]." ".$data["surname"]."'";
echo $emil;
问题是给定名称=>'A name'
我生病了,找不到语法
$to[ ]= $emil;
}
}
foreach ($to as $address => $name)
{
if (is_int($address)) {
$message->setTo($name);
} else {
$message->setTo(array($address => $name));
}
$numSent += $mailer->send($message, $failedRecipients);
}
printf("Sent %d messages\n", $numSent);
拜托,其他一切都正常了,只是少了这一点。谢谢您以错误的方式定义了
$to
数组
使用此选项可在阵列上添加项
$to[$data["email"]] = $data["firstname"]." ".$data["surname"];
// ^ Index ^ Value
稍后,当您使用foreach
循环时,它将很好地区分为$address和$name,就像您现在所做的那样
foreach ($to as $address => $name) {
echo $address;
echo $name;
}
非常感谢,我要把我的代码:))再次非常感谢
foreach ($to as $address => $name) {
echo $address;
echo $name;
}