php - 从数组中查找数据并对数组中可用日期的一些字段求和
问题描述
[0] => stdClass Object
(
[time_a] => 2018-11-12 01:46:30
[position_a] => 27.554236,77.750984
[time_b] => 2018-11-12 02:29:28
[position_b] => 28.039742,77.592578
[duration] => 42 58
[route_length] => 58.37
[fuel_consumption] => 6.14
[fuel_cost] => 443.61
)
[1] => stdClass Object
(
[time_a] => 2018-11-12 02:34:37
[position_a] => 28.039742,77.592578
[time_b] => 2018-11-12 02:41:33
[position_b] => 28.118502,77.575138
[duration] => 6 56
[route_length] => 9.41
[fuel_consumption] => 0.99
[fuel_cost] => 71.53
)
[2] => stdClass Object
(
[time_a] => 2018-11-11 02:58:07
[position_a] => 28.118502,77.575138
[time_b] => 2018-11-12 04:20:28
[position_b] => 28.710197,77.204809
[duration] => 1 22 21
[route_length] => 85.43
[fuel_consumption] => 8.99
[fuel_cost] => 649.53
)
[3] => stdClass Object
(
[time_a] => 2018-11-11 06:16:04
[position_a] => 28.710197,77.204809
[time_b] => 2018-11-12 06:48:20
[position_b] => 28.651432,77.112353
[duration] => 32 16
[route_length] => 14.42
[fuel_consumption] => 1.54
[fuel_cost] => 111.27
)
[4] => stdClass Object
(
[time_a] => 2018-11-13 22:20:20
[position_a] => 28.651432,77.112353
[time_b] => 2018-11-12 23:11:16
[position_b] => 28.497530,77.087215
[duration] => 50 56
[route_length] => 25.82
[fuel_consumption] => 2.71
[fuel_cost] => 195.80
)
[5] => stdClass Object
(
[time_a] => 2018-11-13 23:17:43
[position_a] => 28.497530,77.087215
[time_b] => 2018-11-12 23:25:23
[position_b] => 28.490739,77.073738
[duration] => 7 40
[route_length] => 1.77
[fuel_consumption] => 0.16
[fuel_cost] => 11.56
)
这是一个数组,我想要,2018-11-12 日期存在的fuel_cost 总和,所有日期都相同,这里是三个日期,所以我只想显示三行,fuel_cost 的总和为三个日期。希望我解释得很好,如果有任何遗漏,请纠正我。
解决方案
推荐阅读
- python - SciPy 是否有用于解析和跟踪与其常量相关的单位的实用程序?
- c++ - 在不编写显式设置器的情况下修改私有类数据成员的便捷方法是什么?模板有用吗?
- python - 如何更快地计算给定节点的最短路径长度?
- database - laravel 应用程序中的时区计算
- flask - 如何使用 Flask WTF 获取 SelectField 的当前值
- ruby-on-rails - 使用 has_many 和 scope 优化页面加载
- python - 将带有一些空白条目的 CSV 导入 mysql 数据库时,如何将这些条目插入为 NULL?
- graphql - 嵌套在可空字段中的 GraphQL 不可空字段
- css - 如何在悬停时将边框底部向上移动?
- mongodb - GraphQL 和 MongoDB - 使用数组“转换为数组失败”