次のような配列があります。
$costs =
Array
(
[0] => Array
(
[amount_set] => 27.99
[amount_cost] => 17
[amount_markup] => 3.6
)
)
Array
(
[0] => Array
(
[amount_set] => 6.99
[amount_cost] => 3.12
[amount_markup] => 1
)
[1] => Array
(
[amount_set] => 16.99
[amount_cost] => 10
[amount_markup] => 2.54
)
)
私が探しているのは、$cost
配列をループして、それぞれの合計値を計算することですamount_set
。
私が使用する場合:
foreach($costs as $cost) {
$amount +=$cost['amount_set'];
}
次に、すべての結合されたamount_set
値の合計を取得しますが、個々の値の合計を取得したいだけです。たとえば、最初の合計は 27.99 になり、2 番目の合計は 23.98 になります。どうすればこれを行うことができますか?