Loop structures: Difference between revisions
Content added Content deleted
(→[[C]]: Removed syntax highlighting) |
(→[[PHP]]: Removed syntax highlighting) |
||
Line 568:
===while===
while(ok()) {
foo();
Line 574 ⟶ 573:
baz();
}
===do-while===
$i = 0;
do {
echo $i;
} while ($i > 0);
===for===
for($i = 0; $i < 10; ++$i) {
echo $i;
}
===foreach===
foreach(range(0, 9) as $i) {
echo $i;
}
foreach is only used for arrays, which is not obvious from the above example
foreach($array as $key => $value) {
echo $key.' is '.$value;
}
==[[PostScript]]==
|