Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
afrdofdwnvtes
· 13y ago · 0 comments
Well how about this then.
foreach(array(1,2,3,4,5) as $x) $i=$i+$x; echo $i;
Comments
[–]
tel
13y ago
The array_reduce answers get closer to what I was looking for. This might be a "one line" answer, but it requires two special forms, assignment, sequencing operators (;), and two fresh variables.
[–]
paul_f
13y ago
This works, is fast enough and readable. Perfectly fine solution to me.