General Community > Scripting Help

While, counting iterations

(1/2) > >>

Study Force:
Hi, general coding question

I have a while statement that ends with count++. $count = 0 is defined outside the while statement.

Is there a way to place the last counted iteration as a variable? For example, if there are 8001 iterations, we set $last_count as 8001.

If so, how can I accomplish this?

Thanks

Arantor:
It'll be in count... the variable doesn't get unset when you leave the loop, at least in PHP.

Study Force:
So echo'ing $count will give me, theoretically, the last count number of 8001?

Arantor:
You could try it and see what happens...

d3vcho(void):
If you do $count = 0 after the loop, then it'll output 0.

Navigation

[0] Message Index

[#] Next page

Go to full version