【发布时间】:2019-11-23 10:21:20
【问题描述】:
我从我的数据库中收集开始和结束日期。我使用函数来确定每天的值。
$array = array();
foreach ($db_value as $key => $value) {
$Variable1 = strtotime($Date1);
$Variable2 = strtotime($Date2);
for ($currentDate = $Variable1; $currentDate <= $Variable2;
$currentDate += (86400)) {
$Store = date('Y-m-d', $currentDate);
$array[] = array( $Store,
$value->Value2);
}
$result = array_merge($array);
}
这给出了输出:
0 => array:2 [▼
0 => "2019-11-24"
1 => "4"
]
1 => array:2 [▼
0 => "2019-11-24"
1 => "10"
]
但是,我想以这样一种方式对数组进行整形,即每天获得第二个字段的总和而不会重复。喜欢:
0 => array:2 [▼
0 => "2019-11-24"
1 => "14"
]
但是,我不能再进一步了。
【问题讨论】: