Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mestanza/0e12f512d59e187cc76730f2ebd3fd9b to your computer and use it in GitHub Desktop.
Save mestanza/0e12f512d59e187cc76730f2ebd3fd9b to your computer and use it in GitHub Desktop.
A quick and easy way to limit a foreach loop in Laravel Blade.
@foreach (array_slice($posts->toArray(), 0, 5) as $post)
<h1>{{ $post['title'] }}</h1>
@endforeach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment