I am receiving an array of arrays, but would like each array to be an object.
I try this:
$objects->each(function($object) {
return new Object($object);
});
but $objects
is unchanged. I feel like based on the description of collection->each() and array_map, and this answer that this should work. But it clearly it doesn't, and a coworker thought I was an alien for thinking it should work.. so I must be missing something.
Is there a really efficient way like this for iterating through a collection and converting arrays to objects? And.. if this isn't what ->each does.. what does it do?