title: Data present in multidimensional array are not displayed correctly
body: <p>I'm trying to get the values from a Query String and add them to an array inside of an array. The output Query String is something like:<br><br>
  <code>add_to_cart.php?product_id=4&amp;product_name=Pizza&amp;quantity=1&amp;additional_id[]=1&amp;additional_quantity[]=3&amp;additional_id[]=4&amp;additional_quantity[]=5</code><br><br>
  I'm getting each <code>additional_id</code> and <code>additional_quantity</code> variables presents in the Query String with the code below. I compare each of the <code>additional_id</code> with the IDs that I have in database table <em>additionals</em> and insert all into an array. The following code exists in my file <strong>add_to_cart.php</strong> file:</p>
  
  <pre><code>if(isset($_SESSION['cart']))
  {
      while ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC))
      {
          extract($row);
          $columns = array
          (
              'product_id_session' =&gt; $product_id_session,
              'product_id' =&gt; $product_id,
              'product_name' =&gt; $product_name,
              'product_price' =&gt; $product_price,
              'quantity' =&gt; $quantity,
              'additionals' =&gt; array()                        
          );
          if(isset($_GET['additional_id']) &amp;&amp; $_GET['additional_id'] != "")
          {
              foreach($_GET['additional_id'] as $additional =&gt; $value)
              {
                  $additional_id = $value;
                  if(isset($_GET['additional_quantity'][$additional]))
                  {
                      $additional_quantity = $_GET['additional_quantity'][$additional];
                      if($additional_quantity &lt;= 0 || $additional_quantity &gt; 5)
                      {
                          $additional_quantity = null;
                      }
                      else
                      {
                          $sql2 = "SELECT additional_id, additional_name, additional_price FROM additionals WHERE additional_id LIKE '{$additional_id}'";
                          $stmt2 = $connection-&gt;prepare($sql2);
                          $stmt2-&gt;execute();
                          while ($row = $stmt2-&gt;fetch(PDO::FETCH_ASSOC))
                          {
                              extract($row);
                              $columns['additionals'][]['additional_id'] = $additional_id;
                              $columns['additionals'][]['additional_name'] = $additional_name;
                              $columns['additionals'][]['additional_price'] = $additional_price;
                              $columns['additionals'][]['additional_quantity'] = $additional_quantity;
                          }
                      }
                  }
              }
          }
          $_SESSION['cart'][$product_id_session] = $columns;
      }
      header('Location: products.php?action=added&amp;product_name=' . $product_name);
  }
  </code></pre>
  
  <p>Once everything is added in the <code>cart</code> SESSION, in the <strong>cart.php</strong> page I'm trying to show the products with their selected additionals and quantities with:</p>
  
  <pre><code>foreach($_SESSION['cart'] as $product)
  {
      echo "&lt;tr&gt;";
          echo "&lt;td&gt;{$product['product_name']}&lt;/td&gt;";
          echo "&lt;td&gt;&amp;#36;{$product['product_price']}&lt;/td&gt;";
          echo "&lt;td&gt;{$product['quantity']}&lt;/td&gt;";
          echo "&lt;td&gt;";
          foreach($product['additionals'] as $additional)
          {
              echo "&lt;p&gt;{$additional['additional_quantity']}x{$additional['additional_name']} - {$additional['additional_price']}&lt;/p&gt;";
          }
          echo "&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  }
  </code></pre>
  
  <p>But I'm doing something wrong, I think these two codes are not working properly.<br>
  My output is embarrassed, something like this:<br>
  <img src="https://i.stack.imgur.com/nLKMa.png" alt="enter image description here"><br></p>
  
  <p>Am I doing it by the right way? Maybe I'm not looping right with <code>foreach</code>, or the additionals are not being added with success? Sorry for the mistakes, I never worked with multidimensional arrays before. Is there a way to do what I am intending to? Thanks!</p>