Shell C99 Php For Free Online
for (init; condition; increment) statement1; statement2; ...
for ($i = 0; $i < 5; $i++) echo $i . "\n";
int main() for (int i = 0; i < 5; i++) printf("%d\n", i); return 0; Shell C99 Php For
for variable in list; do command1 command2 ... done Here, variable is the name of the variable that will take on the value of each item in the list on each iteration. The list can be a sequence of numbers, a list of files, or any other list of items.
This will output the numbers 0 to 4.
Example:
| Language | Syntax | Example | | --- | --- | --- | | Shell | for variable in list; do ... done | for i in 1 2 3; do echo $i; done | | C99 | for (init; condition; increment) ... | for (int i = 0; i < 5; i++) printf("%d\n", i); | | PHP | for (init; condition; increment) ... | for ($i = 0; $i < 5; $i++) echo $i . "\n"; | for (init; condition; increment) statement1; statement2;
In PHP, the for loop is used to iterate over a block of code for a specified number of times. The basic syntax of a PHP for loop is as follows:
Example: