Let's say that you have an array of 30 characters and you are looping through them to build a visual grid in HTML. I want to know when it's on the last row of items and apply a CSS rule. For every 8th item, I can use the code below to apply an additional CSS rule:
$cnt=1;
foreach ($characters as $index => $character){
if ($cnt % 8==0) echo "newline";
$cnt++;
}
Since I only have 30 characters, there will be 3 lines with a shorter 4th line (it will only have 6 items). How can I flag every character from 24-30 as belonging to the last row. The total number of characters will always vary.