Reputation: 191
I want to fetch only two columns data from table 1st column data as array key and another column data as array value.
as array['wid'=>'temp']
result should be array['1'=>'1.5','2'=>'11.50']
for laravel 5.4
Upvotes: 0
Views: 1798
Reputation: 191
This worked for me.
$data = DB::table('city_list')->select('cid','city_name')->get();
$val = array();
foreach ($data as $key => $value) {
$val[$value->cid]=$value->city_name;
}
Upvotes: 0