// combine() - ключі + значення
$headers = collect(['name', 'email', 'age']);
$row = ['John', 'john@ex.com', 30];
$user = $headers->combine($row);
// ['name' => 'John', 'email' => 'john@ex.com', 'age' => 30]
// zip() - попарне склеювання
$names = collect(['John', 'Jane']);
$ages = [30, 25];
$pairs = $names->zip($ages);
// [['John', 30], ['Jane', 25]]
// zip() з нерівною довжиною - null у хвості
collect([1, 2, 3])->zip([10, 20]);
// [[1, 10], [2, 20], [3, null]]
// Кілька колекцій одночасно
$names->zip($ages, $emails);
// [['John', 30, 'john@ex.com'], ...]
// Парсинг CSV одним ланцюжком
$lines = collect(file('users.csv'));
$headers = str_getcsv($lines->shift());
$users = $lines->map(fn ($line) =>
collect($headers)->combine(str_getcsv($line))
);
// $users[0]['email'] - асоціативний доступ
// Зіставлення двох запитів у мапу
$map = Order::pluck('id')
->combine(Order::pluck('total'));
// [1 => 250.00, 2 => 130.50]