$collection = collect(range(1, 9));

$chunks = $collection->chunk(2);

$labeld = $chunks->mapSpread(function ($odd, $even) {
return "Odd: {$odd} Even: {$even}";
}); $numbers = collect([3, 5, 7]);
$words = collect(['three', 'five', 'seven']); $results = $numbers->zip($words)
->mapSpread(function ($number, $word) {
return $number . '=' . $word;
}); dd($labeld->toArray(), $results->toArray());

  

laravel mapSpread 例子-LMLPHP

05-19 03:17