Formatting after certain amount of data

G’day to all,

I have made a query to the database to retrieve data. I call the data through an array that is placed into a table (html), what I would like to achieve is to be able to add content and formatting after every 5th row called from the database. How would I go about this?

Add a variable which increments by 1 with each iteration.
once it turned 5, do your formatting and make in zero.