Selectively incrementing a variable for presentation purposes. Details inside

I’m making a table of mortgage payments and over the life of a mortgage, there may be 360 payments. I want to show payments from today onwards which may be in the middle of the payment. So, let’s say I’m on payment 212 of 360. I want to show 212, then 215 and every 5 years thereafter.

I thought of doing a for loop that shows the first value and then something like

if ($n % 5 == 0) { show a value }

There has to be a better way though. Any ideas?

Not far off. Lets try some stepping instead.
So you start with $n = 212.

echo $n (or whatever the echo should be for $n = 212)
for($i = $n + (5-($n%5)),$i <= 360; $i += 5) {
echo $i (or whatever echo should be)
}

(5-($n%5)) is “Find the distance to the next-highest multiple of 5”.

Very clever! Thanks for that!