'while' loop

tot 12 tellen:

while ($count <= 12) {
echo $count . ' ';
++$count;
}

Resultaat is:

1 2 3 4 5 6 7 8 9 10 11 12

Nog even met 'for' loop iets proberen:

for ($count = 1; $count <= 12; $count = $count + 1) {echo $count . ' ';}

1 2 3 4 5 6 7 8 9 10 11 12

De tafel van twaalf is:

$count = 1;
while ($count <= 12)
{
echo "$count keer twaalf is " . $count * 12 . "
"; ++$count;
}

Resultaat:

1 keer twaalf is 12
2 keer twaalf is 24
3 keer twaalf is 36
4 keer twaalf is 48
5 keer twaalf is 60
6 keer twaalf is 72
7 keer twaalf is 84
8 keer twaalf is 96
9 keer twaalf is 108
10 keer twaalf is 120
11 keer twaalf is 132
12 keer twaalf is 144