Suppose we have a form and we want from user to select from a list of check boxes and check his favorite choices, post that data as an array and we want to display that data by calling array and arranging it in a loop. Then for this purpose consider following example.
(more…)
PHP For Loop
For loop consists of three phases. i.e.
- Define
- Condition
- Increment or decrement
First we define something. Then we apply a condition and then under that condition we increment or decrement that defined thing.
In complex way;
- The first part is an expression that is evaluated once when the loop begins.
- The second part is the condition. While the condition is true, the loop continues repeating. If the condition is false to start with, the following code block is not executed at all.
- The third part is an expression that is evaluated once at the end of each pass of the loop.
(more…)