I\'m reading an ebook on PHP right now, and the author noted that the difference between a while loop and a for loop is that the for loop will count how many times it runs.<
A for-loop
for (INIT; CONDITIONS; UPDATE) { BODY }
is basically the same as a while-loop structured like this:
INIT while (CONDITIONS) { BODY UPDATE }
While you could technically use one or the other, there are situations where while works better than for and vice-versa.
while
for