我希望将$ total输出为一个数字的总和,但是每次我总结$ total时,它都会输出多个数字
$total =0 // i tried to use a number to sum them up
$computers = array(
"computer;DT-12;568,36;10",
"Samsung; RS; 562,26;11",
"Hewlett Packard; F12; 450,23; 23",
"Toshiba; LO-34; 454,23;8",
"Sony; Vaio 123; 232,23;5"
);
foreach($computers as $value)
{
$product= explode(";",$value);
$price = $product[2];
$count = $product[3];
$multiply = $count * $price;
$total += $multiply
}
预期输出:
$total = 27004 as one number
拉风的咖菲猫