title: How to fix "Undefined offset" error
body: <p>I'm trying to create a simple average calculator using an array with randomly generated numbers. I think the code is pretty solid but I'm being returned this error:</p>
  
  <pre><code>Notice: Undefined offset: 10 in ../average/averageresults.php on line 31
  </code></pre>
  
  <p>Line 31:</p>
  
  <pre><code>for ($i=0; $i&lt;=10; $i++)   {   echo $array[$i]."&lt;br /&gt;";   }
  </code></pre>
  
  <p>Rest of code is as follows:</p>
  
  <pre><code>&lt;?php
  $array = array();
  
      $array[]=rand(1, 99);
      $array[]=rand(1, 99);
      $array[]=rand(1, 99);
      $array[]=rand(1, 99);
      $array[]=rand(1, 99);
      $array[]=rand(1, 99);
      $array[]=rand(1, 99);
      $array[]=rand(1, 99);
      $array[]=rand(1, 99);
      $array[]=rand(1, 99);
  
  $i=0;
  $sum = array_sum($array);
  $count = count($array);
  $avg = $sum/$count;
  
  for ($i=0; $i&lt;=10; $i++)
    {
    echo $array[$i]."&lt;br /&gt;";
    }
  echo "The average of these numbers is: ".$avg;
  
   ?&gt;
  </code></pre>