Simplify list to associative array conversion #148
This commit is contained in:
parent
33cbceaa92
commit
3c78b5f1e2
@ -37,13 +37,16 @@ if(!function_exists('list_to_assoc')) {
|
||||
* ['item1' => 'item1', 'item2' => 'item2']
|
||||
*
|
||||
* @param array $list
|
||||
* @return \Illuminate\Support\Collection
|
||||
* @return array
|
||||
*/
|
||||
function list_to_assoc(array $list)
|
||||
{
|
||||
return collect($list)->mapWithKeys(function ($item) {
|
||||
return [$item => $item];
|
||||
});
|
||||
$ret = [];
|
||||
foreach($list as $item) {
|
||||
$ret[$item] = $item;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user