Add explanation about loops (#31343)

This commit is contained in:
Tankica
2018-12-29 22:52:01 +01:00
committed by Randell Dawson
parent a31507ecd0
commit 6bbf1c0c53

View File

@@ -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>