for
The for
construct performs a statement (block of code) for a set of conditions defined as follows:
for (start condition; end condition; increment function) { statement(s)}
The start
condition is set at the beginning of the loop. Each time the loop is executed, the increment
function is performed until the end condition is achieved. This looks much like the traditional for/next
loop. The following code is an example of a for
loop:
for ($i=1; $i<=10; $i++) { print "$i\n"}
Get Ubuntu Unleashed 2013 Edition: Covering 12.10 and 13.04, Eighth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.