Hacker News new | ask | show | jobs
by afrdofdwnvtes 4635 days ago
Well how about this then.

    foreach(array(1,2,3,4,5) as $x) $i=$i+$x; echo $i;
2 comments

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.
This works, is fast enough and readable. Perfectly fine solution to me.