title: echo Session array value- warning Illegal string offset
body: <p>I'm trying to add cart function into a websites using SESSION, the items were store into SESSION but i have this Warning: Illegal string offset 'pcode' when i try to echo out the array value</p>
  
  <pre><code>$itemArray = array('pcode'=&gt;$_GET['code']);
  $_SESSION['cart_item'] = $itemArray;
  </code></pre>
  
  <p>This is how i store the array into session</p>
  
  <pre><code>foreach ($_SESSION['cart_item'] as $item){
                  echo $item['pcode'];
                  }
  </code></pre>
  
  <p>and this is how i echo my store array. I'm quite new to PHP and have been trying to build a websites from scratch. I wonder why the WARNING keep on showing on my page. thanks</p>