Hi all, I am trying to get a for loop to cycle through, sleep, and then keep going until a specified time. I'm running into memory errors and unsure whether this is legitimate, or because its created a memory leak. My code is:
$currentTime = time();
$time = time();
while ($currentTime < $time + 1800)
{
for($i = 0; $i < 180; $i++)
{
//code
if($i == 180 -1):
$i = 0;
sleep(600);
endif;
$currentTime = time();
}
}
My logic is that when the for loop gets to the end, it resets it self for the next set, and when it wakes up again it can start from the beginning. It will do this until the current time equal approaches the $time + 1800 value.... Is this the correct approach? It's a hard issue to diagnose since the error is simply a memory one.