On Wed, Oct 7, 2009 at 3:58 PM, Andrew Ballard <aballard@xxxxxxxxx> wrote: > On Wed, Oct 7, 2009 at 3:42 PM, tedd <tedd.sperling@xxxxxxxxx> wrote: > >> However, what I find wacky about all of this is: >> >> for($i=1; $i<=10; $i++) >> { >> echo($i); >> } >> >> and >> >> for($i=1; $i<=10; ++$i) >> { >> echo($i); >> } >> >> Do exactly the same thing. I would have expected the first to print 1-10, >> while the second to print 2-10, but they both print 1-10. >> >> Cheers, >> >> tedd >> >> > Not wacky at all. Think of them both this way: > > <?php > $i = 1; > while ($i <= 10) { > $i++; > echo ($i); > } > > // or > > $i = 1; > while ($i <= 10) { > ++$i; > echo ($i); > } > > ?> > > Andrew > oops. Flip the lines inside the while, but you get the idea. $i = 1; while ($i <= 10) { echo $i; $i++; } Andrew