title: Undefined offset [5]
body: <p>I have an array with the following structure:</p>
  
  <pre><code>[1]=&gt;
      [1]=&gt;
    array(13) {
      [0]=&gt;
      string(8) "Avg. CPC"
      [1]=&gt;
      string(6) "Budget"
      [2]=&gt;
      string(13) "Budget period"
      [3]=&gt;
      string(3) "CTR"
      [4]=&gt;
      string(11) "Campaign ID"
      [5]=&gt;
      string(6) "Clicks"
      [6]=&gt;
      string(10) "Conv. rate"
      [7]=&gt;
      string(4) "Cost"
      [8]=&gt;
      string(12) "Cost / conv."
      [9]=&gt;
      string(3) "Day"
      [10]=&gt;
      string(11) "Impressions"
      [11]=&gt;
      string(7) "Network"
      [12]=&gt;
      string(17) "Total conv. value"
    }
    [2]=&gt;
    array(13) {
      [0]=&gt;
      string(7) "3675556"
      [1]=&gt;
      string(8) "40000000"
      [2]=&gt;
      string(3) "day"
      [3]=&gt;
      string(6) "17.65%"
      [4]=&gt;
      string(9) "405105304"
      [5]=&gt;
      string(1) "9"
      [6]=&gt;
      string(5) "0.00%"
      [7]=&gt;
      string(8) "33080000"
      [8]=&gt;
      string(1) "0"
      [9]=&gt;
      string(10) "2016-05-07"
      [10]=&gt;
      string(2) "51"
      [11]=&gt;
      string(14) "Search Network"
      [12]=&gt;
      string(3) "0.0"
    }
    .
    .
    .
    .
    [32]=&gt;
      array(13) {
      [0]=&gt;
      string(5) "Total"
      [1]=&gt;
      string(8) "40000000"
      [2]=&gt;
      string(2) "--"
      [3]=&gt;
      string(5) "7.15%"
      [4]=&gt;
      string(2) "--"
      [5]=&gt;
      string(3) "194"
      [6]=&gt;
      string(5) "0.00%"
      [7]=&gt;
      string(9) "639390000"
      [8]=&gt;
      string(1) "0"
      [9]=&gt;
      string(2) "--"
      [10]=&gt;
      string(4) "2713"
      [11]=&gt;
      string(2) "--"
      [12]=&gt;
      string(3) "0.0"
  </code></pre>
  
  <p>I try to make an average of every 5th entry </p>
  
  <pre><code>[5]=&gt;
          string(1) "9"
  </code></pre>
  
  <p>Except for the first part (where it is presented the legend of the array) and last part </p>
  
  <pre><code>[32]=&gt;
          array(13) {
          [0]=&gt;
          string(5) "Total"
  </code></pre>
  
  <p>Where is presented the total.
  The code I am using is:</p>
  
  <pre><code>$sum = 0;
  $pathClicks = $data-&gt;data[1];
  foreach($pathClicks as $key =&gt; $item){
     if($key &gt; 1)   {
        $arrayClicks[] = [$item[5]];
        $sum += $item[5];
     }
  } 
  $avgClicks = ($sum / count($arrayClicks)); 
  var_dump($avgClicks);
  </code></pre>
  
  <p>But i get the error: undefined offset [5]. Any ideas why?
  var_dump for $item:</p>
  
  <pre><code>array(13) { `
  [0]=&gt; string(7) "3452000" 
  [1]=&gt; string(8) "40000000" 
  [2]=&gt; string(3) "day" 
  [3]=&gt; string(6) "13.70%" 
  [4]=&gt; string(9) "405105304" 
  [5]=&gt; string(2) "10" 
  [6]=&gt; string(5) "0.00%" 
  [7]=&gt; string(8) "34520000" 
  [8]=&gt; string(1) "0" 
  [9]=&gt; string(10) "2016-06-29" 
  [10]=&gt; string(2) "73" 
  [11]=&gt; string(14) "Search Network" 
  [12]=&gt; string(3) "0.0" }`
  </code></pre>