Loops allow us to iterate group of instructions, that is to say, repeat the execution of a group of instructions as long as a condition is complied with.
As long as the condition is true, the execution of the instructions within the "while" statement will be repeated.
In the following example, at the beginning the value of $i is 0, during the execution of the loop, 1 is being added to the value of $i so that when the value of $i is 10 it does not comply with the condition and the execution of the loop is over.
The statement "for" is the most complete of loop statements. It allows us to control the whole operation of the loop with only one statement.
The first parameter of "for" is executed the first time and it is used to initiate the variable of the loop, the second parameter indicates the condition to be achieved so that the loop will continue executing, and the third parameter is a statement that executes at the end of every iteration and modifies the value of the iteration variable.