【发布时间】:2017-12-30 01:26:47
【问题描述】:
我有一个如下所示的数组:
Array
(
[0] => stdClass Object
(
[products_name] => Parla to gold(Flower)
[measurement] => 18
[unit] => mm
[products_size_height] => 0
[products_size_width] => 0
[products_size_unit] => inch
[products_type] => 4
[products_thickness_measurement] => 18
[product_ordered_pcs] => 4
[product_ordered_quantity] => 100
[others_feature] =>
[rate] => 500
[amount] => 50000
)
[1] => stdClass Object
(
[products_name] => Parla to gold(Flower)
[measurement] => 18
[unit] => mm
[products_size_height] => 0
[products_size_width] => 0
[products_size_unit] => inch
[products_type] => 4
[products_thickness_measurement] => 18
[product_ordered_pcs] => 0
[product_ordered_quantity] => 45
[others_feature] =>
[rate] => 45
[amount] => 2025
)
[2] => stdClass Object
(
[products_name] => Parla to gold(Flower)
[measurement] => 18
[unit] => mm
[products_size_height] => 0
[products_size_width] => 0
[products_size_unit] => inch
[products_type] => 2
[products_thickness_measurement] => 18
[product_ordered_pcs] => 4
[product_ordered_quantity] => 100
[others_feature] =>
[rate] => 850
[amount] => 85000
)
.......
现在我想对同一个产品进行分组(产品将通过 products_name、measurement 和 products_type 的组合来识别)以一次显示一个产品,并对同一产品的“product_ordered_quantity”进行总计。看图你就明白我想说什么了。我将生成 PDF 文件,所以请不要使用 javascript。
结果:
我想要:
【问题讨论】:
-
你尝试过做什么?请发布一些您至少尝试过的证据
-
您可以制作数组并通过填充器或映射 php 函数将您的产品分组到该数组中......而不仅仅是显示您想要的数据
-
我有一个从 laravel 集合中获得的数组,现在我想在表格上显示与第二张图片完全相同的结果。
-
如果您从 db 查询中获取此数据,则更容易实现您所需要的。如果您确认它来自对数据库的查询,我可以为您提供答案
-
是的,它来自对 DB @gbalduzzi 的查询