title: Loop breaks after certain amount of iteration
body: <p>I've a job to do some migration on wordpress sites, although I don't think wordpress has anything to do with my problem. 
  So I'm getting a set of data from a table (id, value) which is serialized. </p>
  
  <p>I want to put the serialized data into arrays, according to the function. The algorithm doing everything fine for the first 86 records.</p>
  
  <p>If I run the algorithm on just 86 records I get all the right data instantly. But when I run it 87 or more times its just goes into loading. Doesn't matter how long the max execution time limit is it's still gonna reach it apparently. </p>
  
  <p>I checked the 87th record if theres something odd with it, but nothing i can see. Is there any idea what could couse this?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>global $wpdb;
  
      $houses_built_years = $wpdb-&gt;get_results('SELECT post_id, meta_value FROM bp100_postmeta WHERE meta_key = "epites_eve"');
  
      foreach ($houses_built_years as $house_built_years) {
          if ($house_built_years-&gt;meta_value) {
              $years = unserialize($house_built_years-&gt;meta_value);
          } else {
              continue;
          }
  
          $build = array(array());
          $series = 0; $year = 0;
  
          while (count($years)) {
              if ($build[$series][$year] &amp;&amp; (min($years) - $build[$series][$year] == 1)) {
                  $year++;
                  $build[$series][$year] = min($years);
                  unset($years[array_search(min($years), $years)]);
              } else if ($build[$series][$year]) {
                  $year = 0;
                  $series++;
                  $build[$series][$year] = min($years);
                  unset($years[array_search(min($years), $years)]);
              } else {
                  $build[$series][$year] = min($years);
                  unset($years[array_search(min($years), $years)]);
              }
          }
  
          $repeater = array();
          foreach ($build as $series) {
              if (count($series) &gt; 1) {
                  $repeater[] = $series[0] . ' - ' . $series[count($series) - 1];
              } else {
                  $repeater[] = $series[0];
              }
          }
      }
  </code></pre>
  
  <p>Here's some example of records (algoithm breaking at id = 30517):</p>
  
  <blockquote>
    <p>30279
    1201
    epites_eve
    a:1:{i:0;s:4:"1898";}</p>
    
    <p>30338
    1202
    epites_eve
    a:1:{i:0;s:4:"1891";}</p>
    
    <p>30397
    1203
    epites_eve
    a:1:{i:0;s:4:"1894";}</p>
    
    <p>30517
    1205
    epites_eve
    a:1:{i:0;s:4:"1897";}</p>
    
    <p>30577
    1206
    epites_eve
    a:1:{i:0;s:4:"1891";}</p>
  </blockquote>