View Single Post
Old 05-12-2008, 12:00 AM   #4 (permalink)
sketchMedia
The Frequenter
Advanced Programmer Top Contributor Good Samaritan 
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 422
Thanks: 22
sketchMedia is on a distinguished road
Default

A nested loops is a loop that has a loop within it. First of all the outer loop's first iteration triggers the inner loop then the inner loop continues until completion, then the outer loop cycles again thus causing the inner again to trigger again.

put into a simple example:

PHP Code:
for($i=0;$i 10$i++)
{
    echo 
'Line '$i 1' ';
    for(
$j=0$j 5$j++)
    {
        echo 
$j;
    }
    echo 
'<br />';

outputs :
Code:
Line 1 01234
Line 2 01234
Line 3 01234
Line 4 01234
Line 5  01234
Line 6 01234
Line 7 01234
Line 8 01234
Line 9 01234
Line 10  01234
basically the first loop out puts : 'Line 1' then the nested loop starts and echos numbers 0-4, then the first loop echos 'Line 2' then triggers the nested loop again and the cycle continues until the first loop finishes.

hope i made that helps
__________________
sketchMedia is offline  
Reply With Quote