View Single Post
Old 05-11-2008, 11:55 PM   #3 (permalink)
Village Idiot
The Gregarious
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 549
Thanks: 15
Village Idiot is on a distinguished road
Default

A nested loop is a loop inside a loop. For instance, if you are reading posts on a forum sequentially, you would read:
Topic 1
Post 1
Post 2
Post 3
Topic 2
Post 1
Post 2
Post 3
So on the so forth.

If you want a purely programmatic example, run this code.
PHP Code:
<?php
for($i=0;$i<10;$i++)
{
    echo 
"Main Level $i - ";
    for(
$j=0;$j<10;$j++)
    {
        echo 
"Sub-Level $j - ";
    }
    echo 
"<br />";
}
?>
Here is what it will output:
http://justanotherportfolio.com/nest.php
__________________
There are two ways to write bug-free code, only the third one works.
Village Idiot is offline  
Reply With Quote