Monday, April 4, 2011

Stops and Skip Loop. PHP & Javascript

//stops a loop and skip loop. Its the same in javascript
//except the variables are named differently
//and substitute echo to document.write('i')
for($i=0; $i<10; $i++) //start at 0; don't go over 10; increment by 1
{
if($i == 2){continue;}//skips
if($i == 4){break;}//stops the loop here
echo "$i, ";
}

No comments:

Post a Comment