Skip to content

Instantly share code, notes, and snippets.

@ericlbarnes
Last active July 13, 2023 07:51
Show Gist options
  • Save ericlbarnes/5771365 to your computer and use it in GitHub Desktop.
Save ericlbarnes/5771365 to your computer and use it in GitHub Desktop.
Limit a foreach with Laravel blade
@foreach (array_slice($posts->toArray(), 0, 5) as $post)
<h1>{{ $post['title'] }}</h1>
@endforeach
@HninEiEaindray
Copy link

@foreach (array_slice($data, 0, 4) as $content)

@ezewer
Copy link

ezewer commented Mar 27, 2018

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment