There is no built-in function in PHP yet to keep statistics of rotations made of loops. Hence, you need to use a counter that will be stored in the file that includes your function.
To store that variable and include that variable in a different PHP page, your function page, you would want to use a session variable
. By default, a session variable stores your variable on the server, not on the clients cookies for around one hour.
You could for instance have $_SESSION['COUNT']
and initiate it to zero in the file that the loop will occur.
When working with session it is important to start the session using session_start
and you would put that at the top of every file using session.
On the function page, you would want to retrieve the session variable and increment it accordingly inside your while loop
.