$r = 0;while($r < count($group)){
$cost = $group[$r]["price_cost"]*$group[$r]["num"];
$r++;}
Output คือ 20
30
30
อยากทราบว่า ต้องเขียนอย่างไรหรือค่ะ ที่จะรวมค่าทั้ง 3 ค่า นั้น ออกมาเป็น 80 ค่ะ
$r = 0;
$sum = 0;
while($r < count($group)){
$cost = $group[$r]["price_cost"]*$group[$r]["num"];
$sum = $sum + $cost;
$r++;
}
ตามนี้ครับ ผลรวมทั้งหมดจะเก็บไว้ในตัวแปร $sum
ขอบคุณค่ะ