- Joined
- Nov 19, 2020
- Posts
- 2,683
- Reaction
- 4,446
- Points
- 1,546
I have a colum that contains multiple names. How will I be able to display them all in a view file separated by new lines? using laravel.
$names = DB::table('users')->pluck('name');
$namesString = implode("\n", $names->toArray());
return view('names')->with('namesString', $namesString);
nl2br
function to replace new lines with HTML line breaks.{{ nl2br(e($namesString)) }}