PHP Tutorial - 13 - php for loop - php foreach loop- how to create for loop in php

Published: 27 September 2016
on channel: Online Classes
2,515
16

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
Parameters:

init counter: Initialize the loop counter value
test counter: Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
increment counter: Increases the loop counter value

The PHP foreach Loop
The foreach loop works only on arrays, and is used to loop through each key/value pair in an array.

~-~~-~~~-~~-~
Please watch: "Php hacks : How to create website step by step using php and mysql : part 8"
   • Php hacks : How to create website ste...  
~-~~-~~~-~~-~


On this page of the site you can watch the video online PHP Tutorial - 13 - php for loop - php foreach loop- how to create for loop in php with a duration of hours minute second in good quality, which was uploaded by the user Online Classes 27 September 2016, share the link with friends and acquaintances, this video has already been watched 2,515 times on youtube and it was liked by 16 viewers. Enjoy your viewing!