News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

While, counting iterations

Started by Biology Forums, January 11, 2018, 01:48:33 PM

Previous topic - Next topic

Biology Forums

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.

Biology Forums

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

Arantor

You could try it and see what happens...

d3vcho

If you do $count = 0 after the loop, then it'll output 0.
"Greeting Death as an old friend, they departed this life as equals"

Illori

can you post the code you are using?

Biology Forums


Advertisement: