There is one element I want to show only once inside this foreach loop. I was wondering if this was possible or if I would need to change my html/css structure for it with Laravel. I only want to show the icon here once.
example.blade.php :
@foreach ($items as $item)
<p>
{{ $item }}
<i class="fa fa-times><!-- this only once --></i>
</p>
@endforeach
Answer from the comments worked best for me :
@foreach ($items as $key => $item)
{{ $item }}
@if($key == 0)
<i class="fa fa-times><!-- this only once --></i>
@endif
@endforeach
You can do this:
@foreach ($items as $item)
<p>
{{ $item }}
<i class="fa fa-times>
@if(!isset($iconShown))
{{ $iconShown = true }}
DisplayIconHere
@endif
</i>
</p>
@endforeach