My Example of loops in PHP
This example uses a for loop to count from 0 to 15 (until our loop variable $i is no longer less than 15). The numbers below were created with a loop in PHP.
While loop demo
While loop: 0
While loop: 1
While loop: 2
While loop: 3
While loop: 4
While loop: 5
While loop: 6
While loop: 7
While loop: 8
While loop: 9
While loop: 10
While loop: 11
While loop: 12
While loop: 13
While loop: 14
While loop: 15
While loop challenge
While loop: 1
1 is odd.While loop: 2
2 is even.While loop: 3
3 is odd.While loop: 4
4 is even.While loop: 5
5 is odd.While loop: 6
6 is even.While loop: 7
7 is odd.While loop: 8
8 is even.While loop: 9
9 is odd.While loop: 10
10 is even.While loop: 11
11 is odd.While loop: 12
12 is even.While loop: 13
13 is odd.While loop: 14
14 is even.While loop: 15
15 is odd.For loop demo
For loop: 15
For loop: 14
For loop: 13
For loop: 12
For loop: 11
For loop: 10
For loop: 9
For loop: 8
For loop: 7
For loop: 6
For loop: 5
For loop: 4
For loop: 3
For loop: 2
For loop: 1
Foreach loop demo
Foreach loop: Surfing
Foreach loop: Swimming
Foreach loop: Biking
Foreach loop: Skateboarding
Foreach loop: Baseball
Foreach loop: Jogging
Continue
01
2
3
4
5
6
7
8
9
11
12
13
14
15
Break loop demo
01
2
3
4
5
6
7
8
9