I have the following array:
$arr = [
0 => 'value1',
1 => 'value2',
2 => 'value3'
];
The select function of my db class takes arguments in the following format:
DB::table('users')->select('value1', 'value2', 'value3')
How can I convert my array to pass those values in my select function?
I tried implode(',', $arr) and it gives one string with comma separated values, but what I want is not a single string, it's a list of comma separated strings like in the example above.
Thanks for any help.
DB::table('users')->select(...$arr)if you're using a modern version of PHP; or simplyDB::table('users')->select($arr), as the select method will accept an array of argumentsDB::table('users')->select("'".implode("','",$array)."'")