Random Sleep time
Posted 19 April 2011 - 06:06 PM
I typically have code pieces:
I would like to be able instead of having a fixed time have one of two solutions
1. A random time between a MAX and MIN number; or,
2. Set up a choice of 5 times and have it randomly pick each time it executes.
This script is in a loop which runs unattended and interacts with various website databases that I own.
Either solutions would work for me.
Posted 19 April 2011 - 06:22 PM
The own fart smells best! ✌
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
Posted 19 April 2011 - 06:25 PM
- 1. Use Random as the argument to Sleep:
This will sleep for a random time between 1 and 10 seconds.
- 2. Use an array to store the times and then use Random to choose which element to use:
You get sleeps of 1, 3, 5, 7 or 9 seconds.
Posted 23 April 2011 - 09:33 PM
Posted 24 April 2011 - 02:41 AM
Global $aTimes = [1, 3, 5, 7, 9]
Wow learn something new everyday! Didn't know you could assign Arrays like that. I would have done it the hard way:
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users