0

所以这里是我从数据库中获取当前信息的地方......

$ci = $currentinfo->fetchAll(PDO::FETCH_ASSOC);

这是我从过去一周获得一些信息的地方...

$pi = $pastinfo->fetchAll(PDO::FETCH_ASSOC);

现在我需要一个foreach将所有信息放入 PHP 邮件函数的语句。类似这样的东西...

foreach ($ci as $civalue) {
foreach($pi as $pivalue)

$result1 = $ci["info1"]-$pi["info1"];
$result2 = etc...
        $body = $result1, etc...;
        $to = '$civalue["email"]';
        $subject = 'Weekly Recap';
        $headers = 'From: noreply@gmail.com';
        mail($to, $subject, $body, $headers);
4

1 回答 1

1

你的意思是这样的:

$result = array();
for ($i = 0; $i < count($ci); $i++) {
    $result[] = $ci[$i]["info1"] - $pi[$i]["info1"];
}


$body = implode(', ', $result);
$to = '$civalue["email"]';
$subject = 'Weekly Recap';
$headers = 'From: noreply@gmail.com';
mail($to, $subject, $body, $headers);
于 2014-01-29T15:57:16.273 回答