It repeats all the script within the loop for as many times as defined.
PHP Code:
// Initiate the variable 'temp.i' at 0
// If temp.i < 20, increase temp.i++
// for each time it needs to do this(temp.i++), it will run the
// script inside of the loop
for(temp.i = 0; temp.i < 20; temp.i ++) {
echo(i);
}
This is useful when you need to do something repetitive, like compare a single value to each element in an array.
PHP Code:
temp.val = 67;
temp.arr = {2,56,23,34,6,78,67,2,34,45,67,8,23424,6,854,21};
// Create a loop the size of the array
for (temp.i = 0; temp.i < arr.size(); temp.i++) {
// compare the defined val to each element in the array
// by using the defined temp.i(which is incremented each loop)
// to scan through the entire array
if (val == arr[temp.i]) {
echo("Teehee! Found you!");
// there's no need to keep scanning the array, so you
// may as well stop looping, which you do via break
break;
}
}