title: Undefined offset: 0 after a loop using arrayholder in laravel 5.2
body: <p>please help me figure this out. I just want to get the total quantity of the same inventory_record_id, as the image is shown below. And I wanted to store that total to an array name <code>$salesQtyArrayHldr</code>. However, it always return the undefined offset 0 error. Please help. Here is my code.</p>
  
  <p><a href="https://i.stack.imgur.com/IAmxV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IAmxV.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;?php 
      $salesQtyArrayHldr = array();
  ?&gt;
  
      @foreach($inventory as $val)
  
       &lt;?php
            for($i = 0; $i &lt; count($val-&gt;sales); $i++){
              if($val-&gt;id == $val-&gt;sales[$i]-&gt;inventory_record_id ){
                  $salesQtyArrayHldr[$i] += $val-&gt;sales[$i]-&gt;quantity; 
              } 
             }  
             var_dump($salesQtyArrayHldr);
      ?&gt;
  </code></pre>
  
  <p>Error</p>
  
  <p><a href="https://i.stack.imgur.com/PUPoa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PUPoa.png" alt="enter image description here"></a></p>