Skip to content

Instantly share code, notes, and snippets.

@ericlbarnes
Last active July 13, 2023 07:51
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • 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