Loops are used to execute the same block of code again and again, as long as a certain condition is true. This saves you from writing the same code multiple times.
The while loop loops through a block of code as long as the specified condition is true.
The do...while loop will always execute the code block once, then check the condition, and repeat the loop as long as the condition is true.
The for loop is used when you know in advance how many times the script should run.
The foreach loop works only on arrays and is used to loop through each key/value pair in an array.
The break statement is used to jump out of a loop. The continue statement breaks one iteration (in the loop) if a specified condition occurs, and continues with the next iteration in the loop.
$x++) in a while loop, otherwise you will create an infinite loop that will crash your browser or server!