2020-04-05 04:35:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Different types of loop statement
|
|
|
|
for($i = 0; $i < 3; ++$i) {
|
|
|
|
|
|
|
|
foreach($foo as $k => $v) {
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($foo2 as $v2) {
|
|
|
|
}
|
|
|
|
|
2020-04-07 06:27:20 +00:00
|
|
|
while(true /* infinite. */) {
|
2020-04-05 04:35:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
} while (true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Loop with no separate body statement
|
|
|
|
while (true) echo "hello";
|
2020-04-05 04:43:27 +00:00
|
|
|
|
|
|
|
// Loop with multiple initialiser conditions
|
|
|
|
for ($i = 0, $e = 3; $i < $e; ++$i) {
|
|
|
|
}
|