Project filters:

Particular projects:

:output hall of fame

best of the :output award

To make it clearer about what the two parameters of the callback are for, and what "reduce to a single value" actually means (using associative and commutative operators as examples may obscure this).

The first parameter to the callback is an accumulator where the result-in-progress is effectively assembled. If you supply an $initial value the accumulator starts out with that value, otherwise it starts out null. The second parameter is where each value of the array is passed during each step of the reduction.

The return value of the callback becomes the new value of the accumulator. When the array is exhausted, array_reduce() returns accumulated value.