php - How to break/pause a loop for X time then start same loop again? -
i have php while
loop sends 3 random numbers 5 in 5 seconds each number sleep(5)
function.
what want when first loop finishes, want break 60 seconds start same loop again.
$i= 1 do{ $one = mt_rand(1, 99); $two = mt_rand(1, 99); $three = mt_rand(1, 99); $this->sendmessage( 'number: '.$one.'' ); sleep(5); $this->sendmessage( 'number: '.$two.'' ); sleep(5); $this->sendmessage( 'number: '.$three.'' ); sleep(5); $this->sendmessage( 'the 3 random numbers has been send, 3 numbers show in 60 seconds.' ); $i++; } while ($i<100);
and here want pause loop 60 seconds, don't want use sleep function pause; want use break stops loop , after 60 seconds starts again.
i have using cli task start code.
i guess might become possible using php threads. see php manual, examples, etc. if wrong, may how async functions calls
Comments
Post a Comment