I wanted to have the result with only the values not with the table column name in Laravel 4.2. For example,
$recs = DB::table(\'table_name\')
->s
You can use the map() and the array_values() methods:
$recs->map(function($i) {
return array_values((array)$i);
})
I'm not sure about Laravel 4.2, but I've just tested it and it works perfectly in Laravel 5.3. If it doesn't work in 4.2, use the native array_map() function instead.
Try
$recs = DB::table('table_name')->pluck('id', 'title');
dd($recs->all());
Reference
Try $recs->flatten()->all()
Update
Since your $recs
looks like an array from your error. Try converting to collection
. I hope this will work on v4.2
$recsCollection = new \Illuminate\Database\Eloquent\Collection($recs);
$recsCollection->flatten()->all();
DB::table('table_name')->all()->lists('id', 'title')->toArray()
Referance: Retrieving A List Of Column Values