The below will print “Hello!” 10 times:
for ($i = 0; $i < 10 ; $i++){ print "Hello!n"; }
Output: Hello!
For iterating through an array it can be handy to use a foreach loop. In the example below the foreach loop will access each variables in the array and allow you to use it as $i:
@array = ('one','two','three');
foreach $i (@array) { print "$i, "; }
Output: one, two, three,