title: Insert and echo elements in multidimensional session array
body: <p>I'm creating a multidimensional array for a php session. Here is the code:</p>
  
  <pre><code>    &lt;?php
      session_start();
      // store session data
  
      $products = array();
      $_SESSION['Products'] = $products;
  
      $products[]= array("Brand"=&gt;$_POST['Brand']);
  
      //retrieve session data
      echo "Product Name = ". $_SESSION['Products'][$products][0]["Brand"];
  
      echo "Product Name = ". $products[0]["Brand"];
  
      ?&gt;
  </code></pre>
  
  <p><code>$_POST['Brand']</code> can be anything like <code>"Adidas"</code> </p>
  
  <p>What I would like is something like this: </p>
  
  <pre><code>Array Session 'Products'
  
     Array '$products'
  
       Sub-Array 'array'
             (
                 "Brand" =&gt; "Adidas"
             )
  
       Sub-Array 'array'
             (
                 "Brand" =&gt; "Nike"
             )
  
       Sub-Array 'array'
             (
                 "Brand" =&gt; "Puma"
             )
  </code></pre>
  
  <p>and so on.</p>
  
  <p>Right now <code>echo "Product Name = ". $products[0]["Brand"];</code> gives me <code>Product Name = Adidas</code> </p>
  
  <p>but <code>echo "Product Name = ". $_SESSION['Products'][$products][0]["Brand"];</code> just gives me <code>Product Name =</code> </p>
  
  <p>My question is, what is the right way to echo the data from a multidimensional array in my case? </p>
  
  <p>Thanks</p>
  
  <p><strong>Edited</strong></p>
  
  <p>Okay I've modified my code to this:</p>
  
  <pre><code>    &lt;?php
      session_start();
      $_SESSION['Products']= array("Brand"=&gt;"Adidas");
  
      echo "Product Name = ". $_SESSION['Products']["Brand"];
      ?&gt;
  </code></pre>
  
  <p>If I only do this then it prints <code>Product Name = Adidas</code> </p>
  
  <p>However if I do this:</p>
  
  <pre><code>    &lt;?php
      session_start();
      $_SESSION['Products']= array("Brand"=&gt;"Adidas");
      $_SESSION['Products']= array("Brand"=&gt;"Puma");
  
      echo "Product Name = ". $_SESSION['Products'][0]["Brand"];
      echo "Product Name = ". $_SESSION['Products'][1]["Brand"];
      ?&gt;
  </code></pre>
  
  <p>Then again no luck. In theory shouldn't this work though?</p>