The incredible FOR Loop Multi-Tasker
Let me introduce you to my little friend “For Loop”. The For Loop is a powerfull little creature for those lazy programmers who develop psychological finger cramps and constantly need shorter and shorter ways to type increasingly complex code. The For Loop comes to the rescue because it allows for everything loop related to be defined in a single line of code! The only loops that could possibly be better are the ReadMyBrain Loops possibly in development by Google?
Here is an example of the incredible For Loop in action:
<php
for ($counter=1; $counter < = 1000; $counter++ )
{
print $counter . "\n";
}
?>
The above code prints the numbers from 1 to 1000 onto the screen, each on a new line. “\n” is the newline character which forces the next print to appear on the line below.
As you can see the For Loop is a powerful creature whom can multi-task by including everything needed on a single line. It is now up to you to take this knowledge and find a more useful application for it than I have above!
Leave a Reply