Add explanation about loops (#31343)
This commit is contained in:
@@ -12,6 +12,18 @@ A loop will continue running until the defined condition returns `false`.
|
||||
|
||||
You can type `php for` , `php while` or `php do while` to get more info on any of these.
|
||||
|
||||
|
||||
## PHP Loops
|
||||
Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal code-lines in a script, we can use loops to perform a task like this.
|
||||
|
||||
In PHP, we have the following looping statements:
|
||||
|
||||
while - loops through a block of code as long as the specified condition is true
|
||||
do...while - loops through a block of code once, and then repeats the loop as long as the specified condition is true
|
||||
for - loops through a block of code a specified number of times
|
||||
foreach - loops through a block of code for each element in an array
|
||||
|
||||
|
||||
### More Information
|
||||
|
||||
- <a href='https://secure.php.net/manual/control-structures.for.php' target='_blank' rel='nofollow'>PHP.net - For Loops</a>
|
||||
|
Reference in New Issue
Block a user