title: PHP while loop execution time
body: <p>I am struggling with the following code and cant find a away to fix it. The page just takes too long to load and "Fatal error: Maximum execution time of 30 seconds exceeded" error appears.</p>
  
  <p>Maybe someone could explain or give an advice?</p>
  
  <pre><code>&lt;?php
  
      $i = 1;
      $s = 1;
      $limit = 21;
      $seasons = 6;
  
      while ($s &lt; $seasons) {
          if ($s &lt; 10) {
              $s = '0' . $s;
          }
  
          while ($i &lt; $limit) {
  
              if ($i &lt; 10) {
                  $i = '0' . $i;
              }
              echo '&lt;input type="checkbox" value="S' . $s . 'E' . $i . '" name="rate"/&gt;S' . $s . 'E' . $i . '&lt;br/&gt;';
              ++$i;
          }
      }
      ?&gt;
  </code></pre>
  
  <p>Thank you</p>
  
  <p><strong>UPDATE:</strong> </p>
  
  <p>After adding an $s++; at the end of firt loop the code was solved of errors and long load but it runs only once no respecting the $seasons = 6 condition. Any idea why would that happen? I tried to remove the 0 prefix and it still not looping till 6</p>
  
  <p><strong>UPDATE:</strong>
  Problem solved, second loop placed in function and it worked. Thanks to all!.</p>
  
  <p><strong>FINAL VERSION</strong></p>
  
  <pre><code>&lt;?php
  
      $s = 1;
      $limit = 21;
      $seasons = 7;
  
      while ($s &lt; $seasons) {
  
          if ($s &lt; 10) {
              $s = '0' . $s;
          }
  
          episodes($s,$limit);
  
      $s++;   
      }
  
      function episodes($s,$limit){
      $i = 1;
  
      while ($i &lt; $limit) {
              if ($i &lt; 10) {
                  $i = '0' . $i;
              }           
             echo '&lt;input type="checkbox" value="S' . $s . 'E' . $i . '" name="rate"/&gt;S' . $s . 'E' . $i . '&lt;br/&gt;';    
              ++$i;
          }
      }
  
  ?&gt;
  </code></pre>