This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Tony Miri
almost 9 years

How do I make this loop work?

Seems simple but I am getting an infinite loop error.

$i = 0;

    do {
        echo "<p>Iteration Number: {$i}</p>";
        $i = $i++;
    }while ($i < 4);

Answer 553532e1d3292fd9ef000080

0 votes

Permalink

So this code displays in the preview window, but says I didn’t write a proper “do” statement.

$i = 0;

    do {
        $i = $i + 1;
        echo "<p>Iteration Number: $i</p>";
        
    }while ($i < 3);

Shouldn’t this be essentially the same as the first code?

points
Submitted by Tony Miri
almost 9 years