This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the workflows category.
Last Updated: 2024-11-21
I wanted to know how to count in a blade.php
loop, each iteration getting an
index basically. So I researched online here:
https://laracasts.com/discuss/channels/laravel/count-in-a-blade-foreach-loop-is-there-a-better-way?page=1
The first solution was really ugly and didn't work. So I went back and saw
someone mention WAY DOWN THE PAGE (i.e. the commend was posted years after the
1st one) that blade has since added $loop->iteration
which was exactly what I
needed.
When looking up how to do something in a forum, start at the most recent (usually the bottom) entry first since the language/framework often introduces new features that make everything easier.
Ideally sort by recency.