【发布时间】:2014-09-28 12:21:34
【问题描述】:
首先,感谢您查看我的问题。
我只想使用 if,else 语句将 $numbers 中的正数相加。
$numbers = array (1, 8, 12, 7, 14, -13, 8, 1, -1, 14, 7);
$total = 0;
if ($numbers < 0 {
$numbers = 0;
}
elseif (now i want only the positive numbers to add up in the $total.)
我是一年级学生,我正在努力理解其中的逻辑。
【问题讨论】:
-
不需要循环。
array_filter()和array_sum()的组合