PHP:Accumulate Adding and Counting
Using an accumulator to add.
list is an array, it holds several integers. For example it might be the list (1,2,3,4).
You can iterate over a list, every time you visit an element of the list you do something to the accumulator
In this example, for every member
$i of the list you add that member to the accumulator using the code
$acc = $acc + $i;
Using an accumulator to count.
Use the accumulator to count the number of items in the list:
Using an accumulator to multiply.
Use the accumulator to find the product of items in the list: