Reputation: 4102
How do I do a line break in a message.
I tried following
$request->session()->flash('message', "first line \r\n second line");
$request->session()->flash('message', "first line <br> second line");
but they did not work, how do I accomplish this?
Upvotes: 5
Views: 24787
Reputation: 2419
If you want to use escaped echoing, you can try:
@foreach(explode('<br>', session('message')) as $msg)
{{ $msg }}
@if(!$loop->last)
<br>
@endif
@endforeach
Upvotes: 2
Reputation: 21681
You can try:
{!! 'first line <br> second line' !!}
Output
first line
second line
And
{!! nl2br(e('first line <br> second line')) !!}
Output
first line <br> second line
Upvotes: 6
Reputation: 163798
Use <br>
but when displaying the messages, use unescaped echoing:
{!! session('message') !!}
https://laravel.com/docs/5.3/blade#displaying-data
Upvotes: 13
Reputation: 34914
Displaying Unescaped Data in laravel like this.
{!! $message !!}
Upvotes: 1