$collection = collect([
[
'name' => '哼',
'department' => '测试',
'email' => '965643796@qq.com'
],
[
'name' => '哈',
'department' => '测试',
'email' => '965643796@qq.com'
]
]);
$keyed = $collection->mapWithKeys(function ($item) {
return [$item['email'] => $item['name']];
});
$keyed->all();
/*结果
[
'965643796@qq.com' => 'John',
'965643796@qq.com' => 'Jane',
]
*/