array_reduce() To Filter And Alter

By Rahul Chavan

Using array_reduce() to create custom data structures goes beyond simple filtering.

array_reduce() might save a second loop. Although, it might also be quite slow, in particular for large arrays (10 millions+).

array_reduce() doesn’t provide keys when processing them.

../_images/array_reduce.png