我想在我的邮件功能中使用foreach,但我不知道该怎么做,(我使用swiftmailer,但我觉得这并不是真的相关)
这是我的代码:
Mail::send('emails.bestelling',
array(
'mededeling' => $bestelcode,
'rekeningnummer' => '000/000000/00',
'naam' => $userNaam,
'totaal' => $totaal,
'producten' =>
foreach ($mand as $rij)
{
$rij->name;
$rij->qty;
}
}
), function($message)
{
$message->from('noreply@test.be');
$message->to('test@test.com', 'Admin')->subject('Creative Displays Bestelling');
});
答案 0 :(得分:1)
在Mail()之外使用foreach,如下所示:
$production_string = '';
foreach ($mand as $rij)
{
$production_string .= "Name : ".$rij->name;
$production_string .= ", Quantity : ".$rij->qty;
}
Mail::send('emails.bestelling',
array(
'mededeling' => $bestelcode,
'rekeningnummer' => '000/000000/00',
'naam' => $userNaam,
'totaal' => $totaal,
'producten' => $production_string
}
), function($message)
{
$message->from('noreply@test.be');
$message->to('test@test.com', 'Admin')->subject('Creative Displays Bestelling');
});