你好,我有這樣的陣列,我需要的Total
總和:如何總和多級陣列
(
[0] => SimpleXMLElement Object
(
[Code] => 1
[Total] => 28.56
)
[1] => SimpleXMLElement Object
(
[Code] => 2
[Total] => 67.99
)
)
我想是這樣的:
$sum = 0;
foreach($myArray as $key=>$value)
{
$sum+= $value;
}
echo $sum;
,但它在返回的數新行不加總結
結果應該是96.55
請幫忙!
$ sum + = $ value-> Total; – coder