title: How to delete a record that stored in nested array foreach php
body: <p>Recently I've been self-learning PHP and doing a project for improving my skills.</p>
  
  <p>I was trying to delete my items which I stored them in session array. First loop is based on renter after that only loop the items from array into cart that belong to that particular renter which this part is working well. </p>
  
  <pre><code>foreach($items as $rentid =&gt; $details){
             $sql = "SELECT * FROM renter WHERE renter_id = $rentid";
             $result = mysqli_query($conn, $sql);
             $row = mysqli_fetch_assoc($result);
          ?&gt;
              &lt;tr&gt;
                  &lt;td&gt;Renter:&lt;?php echo $row['name'];?&gt;&lt;/td&gt;
                  &lt;/tr&gt;
          &lt;?php
              foreach($details as $d){
                  $item_id = $d['item_id'];
                  $qty = $d['qty'];
                  $start_date = $d['start_date'];
                  $end_date = $d['end_date'];
  </code></pre>
  
  <p>I was using this code to store the value from form</p>
  
  <pre><code>$items[$renter_id][] = [
      'item_id' =&gt; $itemid 
    , 'qty' =&gt; $qty
    , 'start_date' =&gt; $start_date
    , 'end_date' =&gt; $end_date
    ];
  </code></pre>
  
  <p>This is the output for array</p>
  
  <pre><code>Array ( 
    [24] =&gt; Array ( 
       [0] =&gt; Array ( 
         [item_id] =&gt; 10 
         [qty] =&gt; 1 
         [start_date] =&gt; 04-09-2016 
         [end_date] =&gt; 06-09-2016 
         ) 
       ) 
    [26] =&gt; Array ( 
       [0] =&gt; Array ( 
          [item_id] =&gt; 6
          [qty] =&gt; 1 
          [start_date] =&gt; 04-09-2016 
          [end_date] =&gt; 14-09-2016 
          ) 
        )
     )
  </code></pre>
  
  <p>[24][26] are renters' IDs</p>
  
  <p>I wanted to delete one of the item from cart but this code I used before didn't work in this array. I've been searching through stackoverflow for hours but can't find the similar array.</p>
  
  <p>This is the code for deleting a row from array</p>
  
  <pre><code>     foreach($_SESSION['cart'] as $key =&gt; $value) {
          foreach($value as $v){
             if($v['item_id'] == $removeditem) {
                unset($_SESSION['cart'][$key]);
              }
           }
        }
  </code></pre>
  
  <p>Please advise me, I'd love to learn from you.
  ps: my friend said this is not a multidimensional array, and I am actually weak in array. Please advise me, again :)</p>