如果我有一个数组:
$data = array(
array(
'manufacturers_id' => 29,
'manufacturers_name' => 'Quicksilver',
'products_quantity' => 1,
'products_price' => 15.6000,
'products_cost' => 8.0000,
),
array(
'manufacturers_id' => 29,
'manufacturers_name' => 'Quicksilver',
'products_quantity' => 2,
'products_price' => 4.6722,
'products_cost' => 2.4000,
)
);
我怎样才能重新格式化它以提供结构
Array
(
[Quiksilver] => Array
(
[brands_sales] => $brandsSalesVal
[brands_products_sold] => $brandsSoldVal
[brands_costs] => $brandsCostsVal
)
$brandsSalesVal
= 所有 products_price * products_quantity 的总和(对于每个制造商 ID)
$brandsSoldVal
= 每个制造商的所有 products_quantity 的总和
$brandsCostsVal
= 每个制造商的所有 products_costs 的总和
非常感谢任何帮助,我感谢任何人花时间回答我相当冗长的查询。我仍在处理重新格式化阵列。