Map occurrences
Mapping works a bit like a combination of all() and forEach(). It returns all matched elements, after
they have been iterated (and potentially altered) using map() callback (which accepts Detail details).
Map matched occurrences#
So instead of returning all elements:
...you can map them - to any other value, by callback:
Variable callbacks#
You can invoke map() with any valid PHP callable which accepts one
string parameter (or no parameters) - just like first().
Arbitrary return types#
Again, just like first(), this method can return values of any type, including: objects, arrays,
booleans and null.
flatMap()#
You can just as easily create a flattened map.
Read more about flatMap() on the next page.