Array
(
[6254] => Array
(
[check] => on
[quantity] => 2
[name] => Testing product_special One Size
[total] => 66.0000
[price] => 33.0000
)
[6255] => Array
(
[check] => on
[quantity] => 1
[name] => Testing card
[total] => 80.85
[price] => 33.0000
)
)
以上是我的阵列。
我的代码
foreach($value as $key2 => $value2){
$name = preg_replace('/\s+/', '', $key);
echo "<pre>";
// print_r(array_sum(array_column($value, 'price')));
print_r($value);
echo "</pre>";
exit;
}
想问一下,如何“具体”加价?试过
$totalprice += $value['price'];
不管用
array_sum(array_column($value, 'price')) < 此代码解决了我的问题
但是有一个新问题,如果需要检查“条件”怎么办
如果 "check" = on 只能求和,如果没有 "check" 忽略数组
慕姐8265434
四季花海