D B
Date Price qty
2012-10-21 $11 150
2012-10-22 $12 90
2012-10-22 $12 10
2012-10-23 $13 250
代码
$result = mysqli_query($con, "SELECT * FROM table ORDER BY 'date'");
while ($row = mysqli_fetch_array($result)) {
$orders[] = array(
'Date' => $row['date'],
'price' => $row['price'],
'Quantity' => $row['qty']
);
}
我不需要获取重复的日期,对于那些重复的日期需要获取平均值price
和总和,Qty
如下例所示:
例子
Date Price qty
2012-10-21 $11 150
2012-10-22 $12 100
2012-10-23 $13 250
我尝试使用Array-map
,但我失败了,非常感谢帮助