我的两个可爱的 JSON 数组有一个很大的问题。
代码如下:
else if ($range == "day") $sqlRangeString = "GROUP BY DATE_FORMAT(dbtime, '%Y-%c-%e')";
$startdate = doTimeStamp($startdate);
$enddate = doTimeStamp($enddate);
if (isset($consumer_on))
{
echo '[';
$counter = 0;
foreach($consumer_name as $consumer_name_value)
{
$result2 = mysql_query("SELECT AVG(loadvalue) AS m1, dbtime, time
FROM $consumer_name_value
WHERE time >= $startdate
AND time <= $enddate
$sqlRangeString
ORDER BY time") or die('#ä');
while ($data2 = mysql_fetch_array($result2))
{
$consumer_value[$counter][0] = $data2['time'];
if (!isset($consumer_value[$counter][1])) $consumer_value[$counter][1] = 0;
$consumer_value[$counter][1] = (float)$consumer_value[$counter][1] + (float)$data2['m1'];
$counter++;
}
}
echo json_encode($consumer_value);
}
if (isset($producer_on))
{
$ounter = 0;
if (isset($consumer_on) && ($consumer_on == 1))echo ',';
foreach($producer_name as $producer_name_value)
{
$result3 = mysql_query("SELECT AVG(power) AS m1, dbtime, time
FROM $producer_name_value
WHERE time >= $startdate
AND time <= $enddate
$sqlRangeString
ORDER BY time") or die('#ää'); ;
while ($data3 = mysql_fetch_array($result3))
{
$producer_value[$counter][0] = $data3['time'];
if (!isset($producer_value[$counter][1])) $producer_value[$counter][1] = 0;
$producer_value[$counter][1] = $producer_value[$counter][1] + (float)$data3['m1'];
$counter++;
}
}
echo json_encode($producer_value);
}
}
?>
我的问题是输出:
为什么 produver_value 数组的输出在每个部分前面都有数字?我怎样才能删除这个?