Syntax for the FOR loop:
for (initial condition; cyclic condition; state change)
{alert (attr{i}) }
Instance for (var i=0; i<5; i++)
Loop Body
1. Determine the condition first (do not meet the bounce loop)
2. (If conditions are met) perform loop body
3. Status change
Php:
Iterating through an array
1.for Loop traversal
For ($i =0, $i <count ($arr)); $i + +)
{
echo arr{$i}i. " <br> "
}
2.forerch Cycle
The first value of the foreach ($arr) as $v) is V, the loop body
{The second value gives V, the loop body
echo $v. " <br> ",,, ...
}
3.lise () and each () combined traversal
While
List ($k, $v) =each ($arr)
{
echo "{$k}-{$v}<br>"
}
4 pointer traversal
Echo current ($arr); takes the current pointer to the value of the element
echo Key ($arr); takes the current pointer to the index of the element
Next ($arr); Adjust the pointer down
Prev ($arr); Adjust the pointer up
Reset ($arr); Reset the pointer
End ($arr); hit the pointer to the last
Do
{
Current ($arr);
}
while (Next ($arr))
While loop first condition, rear loop body
Do while first loop body, in condition
JS for Loop and PHP loop