Using @for Control Structures in Blade

Problem

You want to use loops in your Blade template.

Solution

Use the @for control structure.

<html>
<body>
  <p>I can count to 10.</p>
  @for ($i = 1; $i <= 10; $i++)
    <p>{{ $i }}</p>
  @endfor
</body>
</html>

Discussion

It's just like PHP's for statement.

But prettier without that ugly <?php tag before it.

comments powered by Disqus