视频中的数组结构是这个样子:
$orders = [[
'id' => 1,
'user_id' => 1,
'number' => '13908080808',
'status' => 0,
'fee' => 10,
'discount' => 44,
'order_products'=> [
['order_id'=>1,'product_id'=>1,'param'=>'6寸','price'=>555.00,'product'=>['id'=>1,'name'=>'蛋糕名称','images'=>[]]],
['order_id'=>1,'product_id'=>1,'param'=>'7寸','price'=>333.00,'product'=>['id'=>1,'name'=>'蛋糕名称','images'=>[]]],
],
]];
你试试你的代码能不能跑通.
即使你使用下面代码来跑通:
$price = array_sum(array_column($orders[0]['order_products'], 'price'));
但是 orders 数组一旦有多个 order,你的代码估计就跪了