From 3c78b5f1e27d36e80b1d3513a572fd42a47e3a14 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 21 Jan 2018 13:59:51 -0500 Subject: [PATCH] Simplify list to associative array conversion #148 --- app/helpers.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/helpers.php b/app/helpers.php index 113714af..eadd706b 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -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; } }