一个不寻常的情况......哈哈
我正在尝试添加一个数组。在某种程度上它起作用,而另一种则没有,但我无法弄清楚它是什么。
我会解释:
我的内心和内幕时间
<?php $i = 1; $b = 0; do { ?>
<td><?php echo $SubtraiMes[] = DemostrativoAno("financ_despesa",$ano,09) ?></td>
<td><?php echo $SubtraiMes[] = DemostrativoAno("financ_despesa",$ano,10) ?></td>
<td><?php echo $SubtraiMes[] = DemostrativoAno("financ_despesa",$ano,11) ?></td>
<td><?php echo $SubtraiMes[] = DemostrativoAno("financ_despesa",$ano,12) ?></td>
<?php $MesSomado = implode(", ",tiraMoeda($SomaMes)); $i++;$b++; } while ($i <= $repetir); ?>
结果出现了
125.70,0.00,0.00,0.00,0.00,0.00,300.00,0.00,0.00,0.005,65.00,0.00,1825.70
在ARRAY E SOMO中放置
<?php $MesSomado = array($MesSomado); echo array_sum($MesSomado); ?>
RESULT
0
但如果我这样做,那就行了
<?php $MesSomado = array(125.70, 0.00, 0.00, 0.00, 0.00, 0.00, 300.00, 0.00, 0.00, 0.00, 65.00, 0.00, 1825.70); echo array_sum($MesSomado); ?>
我做错了什么?
答案 0 :(得分:2)
如果$MesSomado
中的当前值为
125.70, 0.00, 0.00, 0.00, 0.00, 0.00, 300.00, 0.00, 0.00, 0.00, 65.00, 0.00, 1825.70
尝试,
<?php $MesSomado = explode(",",$MesSomado); echo array_sum($MesSomado); ?>
我认为你可以得到正确答案。