简体   繁体   English

循环显示每个项目

[英]Display each item in loop

I have a form that post an array and I loop over the array which I want to display in an email. 我有一个发布数组的表单,并且在要在电子邮件中显示的数组上循环。

$qty = $_POST['qty'];
foreach($qty as $value)
{
  $qtyOut = $value . "<br>";
}

I then want to get the $qtyOut of each one and display in my email. 然后,我想获取每个中的$qtyOut并显示在我的电子邮件中。

my email looks like so. 我的电子邮件看起来像这样。

$message = "An order was submitted from: " . $additionalEmail . "<br/><br/>"
. "Customer Name: " . $custName . "<br/>"
. "Email:" . $customerEmail . "<br/>"
. "Message: <br/>"
. "<pre>" .$custName . "<br> "
. "Qty: ". $qtyOut . "Desc: " . $desc . "Options :" . $options . "Price : " . $price . "</pre>"
. "Submitted at: ". $time;

$message = wordwrap($message, 70, "\r\n");

I would like to have the: 我想拥有:

. "Qty: ". $qtyOut . "Desc: " . $desc . "Options :" . $options . "Price : " . $price .

Display as many times as there are order lines to fill the email. 显示尽可能多的订单行以填充电子邮件。

Can somebody point me in the right direction please, as only the last line is displayed that was entered. 有人可以指出我的正确方向,因为只有最后一行显示。

You are redefining your $qtyOut variable. 您正在重新定义$qtyOut变量。 Instead of 代替

$qtyOut = $value . "<br>";

Use: 采用:

$qtyOut .= $value . "<br>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM