title: php using loop to restart time limit for script execution
body: <p>I'm running a foreach loop in php which takes longer to execute than my maximum execution time of 30 seconds. The loop sends individual emails to users. </p>
  
  <p>Instead of running cron jobs every 30 seconds and creating queues for records is it unethical to just restart the counter in the loop using <code>set_time_limit(30)</code> ? </p>
  
  <pre><code>$i = 0; //start count from 0
  
  foreach ($users as $user): 
  
      //limit emails sent
      if(++$i == 100) break; //ends execution of loop
  
      set_time_limit(30); //restart timeout counter
  
      send_email($user); //send email to user
  
  endforeach;
  </code></pre>
  
  <p>I'm new to this but with the code above I think I'm giving each email 30 seconds to complete but also breaking the loop when 100 emails are sent so the script doesn't run forever.</p>
  
  <p><strong>Update:</strong> <code>set_time_limit(0)</code> goes against hosting TOS, I believed that restarting the timeout counter restarts the script as well as would CRON</p>