![]() The for statement is used when you know how many times you want to execute a statement or a block of statements. This loop can be used if you want to repeat a piece of a code a certain number of times. We will discuss about continue and break keywords used to control the loops execution. There are several interesting loops in PHP. The break statement can also be used to jump out of a loop. It was used to 'jump out' of a switch statement. While − loops through a block of code if and as long as a specified condition is true.ĭo.while − loops through a block of code once, and then repeats the loop as long as a special condition is true.įoreach − loops through a block of code for each element in an array. You have already seen the break statement used in an earlier chapter of this tutorial. Second, start the loop by setting the variable i to 1. PHP supports following four loop types.įor − loops through a block of code a specified number of times. PHP for statement example First, initialize the total to zero. ![]() Loops in PHP are used to execute the same block of code a specified number of times. Loops in PHP are used to execute the same block of code a specified number of times.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |