PHP loops
In this tutorial I will show you all loops in PHP and their usage with code examples.
Step 1 - PHP loops
PHP loops
PHP loops are control structures and you can use them the execute a code block more times. It means you don't have to copy and paste your code many times in the file just use a right loop statement.
A basic example:
Code:
And the output of both code is similar:
Output:1 2 3 4 5 6 7 8 9
After this short example let's see what kind of loop statements are in PHP.
- while loop
- do ... while loop
- for loop
- foreach loop
- break
- continue
Next Step of PHP loops
Tags: php loops, for loop, while loop, freach loop, loop
| PHP loops - Table of contents |
|---|
| Step 1 - PHP loops |
| Step 2 - The PHP while loop |
| Step 3 - The do while loop |
| Step 4 - The for loop |
| Step 5 - The foreach loop |
