array_sum/array_column(二维数组指定字段求和)
二维数组指定字段求和
<?php $arr = [ [ "goods_id" => 37, "goods_name" => "铁砂锅37", "goods_weight" => 2, "goods_price" => "200.00", "actual_delivery_sum" => 1, "order_goods_num" => 1, ], [ "goods_id" => 39, "goods_name" => "料酒39", "goods_weight" => 1, "goods_price" => "30.00", "actual_delivery_sum" => 1, "order_goods_num" => 0, ] ]; $coupon_price = array_sum(array_column($arr, 'goods_price')); echo $coupon_price;//230