To loop through values, use the for loop. Here a small example that explains it all:
for ($counter = 0; $counter <= 10; $counter++)
{ print $counter."," }
0,1,2,3,4,5,6,7,8,9,10,
Makes sense. $counter++ means, that $counter will be increased one by one and is short for $counter = $counter + 1. You can also use it with a minus, making it $counter- - . But you can do a little bit more while you are in a loop. Place any of the commands into the loop and you con do this:
last Exit the loop immediately
redo Repeat the last run in the loop
next Proceed to the next run, don't run any command after this in the loop
The main use for those is, if you have to change the standard loop behaviour under special circumstances or rules, when you want to abort the loop and so on.