Contact Us || Privacy Policy || About Us |
|
Loops Statement in PHPPHP loops Statements are used to execute the same block of code again and again. Types of Loops in PHPPHP supports 4 different types of loops.
1) For Loop in PHPfor loop repeats a block of code until a certain condition is that means execute a block of code for certain number of times. Syntax Flowchart![]() Example :-Output Number is: 0 Number is: 1 Number is: 2 Number is: 3 Number is: 4 Number is: 5 2) While Loop in phpif the while loop condition is true then executes a block. Other wise sikp it. Syntax PHP While Loop Flowchart![]() Example :-Output The number is: 1 The number is: 2 The number is: 3 The number is: 4 The number is: 5 3) do...while Loop in PHPdo...while loop will always execute the block of code once it will check the condition, and repeat the loop while the specified condition is true. Syntax: Output Example :-4) foreach Loop in PHPonly works on arrays and is used to loop through each key/value pair in an array. Syntax Output java php html css |