I have this view :
<p style="text-align: center;"><strong>
@foreach($journal->user as $item)
{{ $item->name }},
@endforeach
</strong></p>
I wanted to remove comma after the last {{ $item->name }} string. How to do it in Laravel 5.3 blade ?
If you're using 5.3, you can use $loop variable for this:
@foreach($journal->user as $item)
{{ $loop->first ? '' : ', ' }}
{{ $item->name }}
@endforeach
The code is from similar question.
Try this
@foreach($journal->user as $item)
{{ $item->name }}
@if (!$loop->last)
,
@endif
@endforeach
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With