0
/*user is filing up form values that includes name , phone , product quantity...etc   */<BR/>
/*After clicking button  */
$mailto = randomuseremail@xxx.com
/* *//
$value1=$_GET['value1'];
$value2=$_GET['value2'];
$value3=$_GET['value3'];
.
.
.
$value20=$_GET['value20'];

$message = <<< EOD
< br> value 1 is:  $value1;
< br> value 2 is: $value2;
< br> value 3 is:  $value3;
.
.
.
< br> value 20 is - $value20;
... EOD ;
$success = mail($mailto, $message , $body, $headers);

用户收到此电子邮件

You orderd: 
value 1 is:  1
value 2 is:  0
value 3 is:  0
...
value 20 is: 0

而不是显示如何过滤/不显示 EOD 中的 0 或“”值(或有更好的方法)这是所需的电子邮件输出:

You orderd:
value 1 is:  1 /*or any other non zero | "" value   */
4

1 回答 1

0
$message = '';
for ($i = 1; $i <= 20; $i++) {
  if ($_GET['value'.$i] != 0) {
    $message .= "<br> value $i is: " . $_GET['value'.$i]
  }
}
于 2012-11-24T07:02:07.167 回答