Is it possible to have a random delay in a loop to process each item? and if so does that affect the php timeout?
I want the random number to occur for each item e.g. first item may have a sleep of 5, whilst next will be 10.
I know the code for random number for 10-100 is below:
$random = (rand(10,100));
However, where do I put this in my code, because I want it to change for each loop.
Also the code to sleep, where would that go:
sleep($random);
Here is my code
<?php
foreach ($ret as $l) {
$id_s = $l['idx'];
$from_s = $l['number'];
$msg_s = $l['msg'];
$timestamp = date("F j, Y, g:i a");
$url = 'index.php?service=insertMsgs×tamp='.$timestamp.'&from='.$from_s.'&msg='.$msg_s;
echo $url;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$output=curl_exec($ch);
curl_close($ch);
$this->deleteSms($id_s);
print_r($output);
}
?>