Friday 19 April 2013

PHP For Loops


Loop / loop will run if the conditions are right / true and still not pass the value of variable limiting the number of repetitions.

Looping / For loop using.
Usually used if you already know the fallow times you have to repeat the syntax that you want to reset.

EXAMPLE:
<? php
for ($ i = 1; $ i <= 5; $ i + +) {
echo 'No'. $ i. '<br />';
}
?>

RESULTS:
No. 1
No. 2
No. 3
No. 4
No. 5

Looping / using foreach loop.
Malakukan foreach loop based on the number of arrays that are stored in the variable.

EXAMPLE:
<? php
$ i = array ('one', 'two', 'three');
foreach ($ i as $ value) {
echo $ value. '<br />';
}
?>

RESULTS:
one
two
three

No comments:

Post a Comment