squiggerz Posted June 8, 2007 Share Posted June 8, 2007 I have been fighting with this for hours.. Below is an excerpt of what I'm working with. I have a list of domains in a text file, I upload the text file through a form to my script. All of this is fine and dandy. I have a checkbox set to ask user if they want to stall for 10 minutes after 400 domains are ran through this script before executing 400 more. I can get the script to count the total amount of domains in the file, I just cant wrap my head around what I'm supposed to do if the counted number of domains reaches 400. if ($sleep) { $counted = count($doms); while ($counted < 400) { execute the script on the domain name; } pseudocode from here on: when $counted == 400 { sleep(600) } then continue till $counted == 800 ... } Anybody have any idea how this can be accomplished? Quote Link to comment https://forums.phpfreaks.com/topic/54720-solved-i-cant-count-no-really/ Share on other sites More sharing options...
Dragen Posted June 8, 2007 Share Posted June 8, 2007 give this a try <?php if($sleep){ $i = 0; foreach($doms as $key => $value){ if($i == '400'){ sleep(600); $i = '0'; } // execute the script on the domain name $i++ } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54720-solved-i-cant-count-no-really/#findComment-270642 Share on other sites More sharing options...
squiggerz Posted June 8, 2007 Author Share Posted June 8, 2007 Thank you so much! I had to rearrange it a bit for it to work with what I had, but it did work, now I can sleep! Thanks again! if($sleep) { $i = 0; foreach($doms as $key => $value) { $domain = trim($value); require 'single.php'; $i++; if($i == '400') { echo "400 domains - resting 10 minutes"; sleep(600); $i = '0'; } } } Quote Link to comment https://forums.phpfreaks.com/topic/54720-solved-i-cant-count-no-really/#findComment-270660 Share on other sites More sharing options...
Dragen Posted June 8, 2007 Share Posted June 8, 2007 I think you'll find that for it to work correctly you'll need the if($i == 400) part before you output single.php. Otherwise I think it will echo 401 records at a time. <?php if($sleep) { $i = 0; foreach($doms as $key => $value) { if($i == '400') { echo "400 domains - resting 10 minutes"; sleep(600); $i = '0'; } $domain = trim($value); require 'single.php'; $i++; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54720-solved-i-cant-count-no-really/#findComment-270675 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.