parent
5e994028ce
commit
ea4431bead
7
%D0%9E-%D1%86%D0%B8%D0%BA%D0%BB%D0%B0%D1%85.md
Normal file
7
%D0%9E-%D1%86%D0%B8%D0%BA%D0%BB%D0%B0%D1%85.md
Normal file
@ -0,0 +1,7 @@
|
||||
Always use **FOREACH** when iterating over a whole array, or at least from the top of an array to a BREAK condition. This way you will never be bitten by an "off by one" error.
|
||||
|
||||
Always use **FOR** when you know (or can easily determine) exactly how many times you need to execute the code in the loop. This is also useful for iterating parts of an array where you aren't always going to be starting from the head.
|
||||
|
||||
Use a **DO-WHILE** when the number of times to have to execute the loop is indeterminate, but you know the code must execute at least once.
|
||||
|
||||
Use a **WHILE** loop when the looping condition could be false as you enter the loop. In other words, there could be conditions where you never execute the loop.
|
Loading…
Reference in New Issue
Block a user