大概试了一下,可以试试下面这个:
$table = [
['AAA', 'BBB', 'CCC', 'DDD', 'EEE'],
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15]
];
$records = collect($items)->except(0)->map(function ($item) use ($table){
return collect($item)->combine(collect($table)->first())->flip();
})->toArray();
我这边的测试结果是:
array:3 [▼
1 => array:5 [▼
"AAA" => 1
"BBB" => 2
"CCC" => 3
"DDD" => 4
"EEE" => 5
]
2 => array:5 [▼
"AAA" => 6
"BBB" => 7
"CCC" => 8
"DDD" => 9
"EEE" => 10
]
3 => array:5 [▼
"AAA" => 11
"BBB" => 12
"CCC" => 13
"DDD" => 14
"EEE" => 15
]
]