title: Why do I occasionally get "Undefined Offset 8?"
body: <p>I have a bit of code that occasionally returns and "Undefined Offset 8."</p>
  
  <p>I searched and I can't find the "Undefined Offset" definitions, making it more mysterious.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>while($lowest_plays !== $plays[$x]){
      $x = rand(0,count($plays));
  }
  </code></pre>
  
  <p>The offset occurs on the while loop, which seems to be where this particular offset usually occurs. The $lowest_plays and $plays variables are always normal and I don't see any pattern for when the "Undefined Offset" occurs.</p>
  
  <p>The variable <code>$x</code> is a random number between <code>0</code> and <code>$plays-1</code>.</p>
  
  <p>Here are the values for one of the "Undefined Offset 8" notices:</p>
  
  <pre><code>Plays: Array ( [0] =&gt; 147 [1] =&gt; 147 [2] =&gt; 146 [3] =&gt; 147 [4] =&gt; 147 [5] =&gt; 146 [6] =&gt; 147 [7] =&gt; 146 ) 
  Lowest Plays: 146
  Random variable ($): 1
  </code></pre>