Level 122
@foreach($comments->take(5) as $comment)
<p>Name user: {{$comment->name}}</p>
<p>Comment: {{$comment->comment}}</p>
@endforeach
4 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Is there a way i can get the first 5 element (comments) of a foreach
@foreach($comments as $comment)
<p>Name user: {{$comment->name}}</p>
<p>Comment: {{$comment->comment}}</p>
@endforeach
@foreach($comments->take(5) as $comment)
<p>Name user: {{$comment->name}}</p>
<p>Comment: {{$comment->comment}}</p>
@endforeach
Please or to participate in this conversation.