I am workign with a Laravel collection and given this code:
use Illuminate\Support\Collection;
$input = ['1234', 42, '12Beers'];
$result = (new Collection($input))->each(static function($item) {
return (int) $item;}
)->toArray();
I'd expect the result to look like:
[
0 => 1234
1 => 42
2 => 12
]
but I'm getting:
[
0 => "1234"
1 => 42
2 => "12Beers"
]
It's as if the each is not being applied. What am I doing wrong?