title: how can i write an algorithm to multiply the total * quantity in a shopping cart using php $_SESSION?
body: <p>I am writing a shopping cart and have my data stored in the $_SESSION array, but would like to  calculate a total. below it the code I thought would work to do this, but it returns '1' in stead of a total!</p>
  
  <blockquote>
    <p><code>$total = array($_SESSION['qty'],$_SESSION['pr']);</code></p>
  </blockquote>
  
  <p>/* I'll give you more code...thanks for your help!!
  here is the code for my php cart:</p>
  
  <pre><code>&lt;?php
  </code></pre>
  
  <blockquote>
    <p>function item_list()
      {
        if(isset($_SESSION['qty'])){
                $total = array($_SESSION['qty'],$_SESSION['pr']);</p>
  </blockquote>
  
  <pre><code>    foreach($_SESSION['qty'] as $key =&gt; $value)
      {?&gt;
          &lt;tr&gt;
      &lt;td align="center"&gt;&lt;?php echo $_SESSION['item'][$key]; ?&gt;&lt;/td&gt;
      &lt;td align="center"&gt;&lt;?php echo $value; ?&gt;&lt;/td&gt;
      &lt;td align="center"&gt;&lt;?php echo $_SESSION['pr'][$key]; ?&gt;&lt;/td&gt;
      &lt;td align="center"&gt;&lt;?php echo array_product($total); ?&gt;
      &lt;/tr&gt;&lt;?php 
      }
  }
  </code></pre>
  
  <blockquote>
    <p>}</p>
    
    <p>session_start();</p>
    
    <p>if(isset($_POST['clear']) &amp;&amp; ($_POST['clear'] == 'clear'))
      {
        session_destroy();
        unset($_SESSION['qty']); 
        unset($_SESSION['item']);
        unset($_SESSION['pr']);
        unset($_POST['qty']); 
        unset($_POST['item']);
        unset($_POST['pr']);
      }</p>
    
    <p>if(!isset($_SESSION['qty']))  $_SESSION['qty'] = array();
      if(!isset($_SESSION['item'])) $_SESSION['item'] = array();
      if(!isset($_SESSION['pr']))   $_SESSION['pr'] = array();</p>
    
    <p>if(isset($_POST['qty']))
      {</p>
  </blockquote>
  
  <pre><code>foreach($_POST['qty'] as $value)
  {
      if(!$value == '') array_push($_SESSION['qty'], filter_var($value, 
  </code></pre>
  
  <blockquote>
    <p>FILTER_SANITIZE_SPECIAL_CHARS));
        }
        foreach($_POST['item'] as $key => $value)
        {
            if(!$_POST['qty'][$key] == '') array_push($_SESSION['item'], filter_var($value, 
       FILTER_SANITIZE_SPECIAL_CHARS));
        }
        foreach($_POST['pr'] as $key => $value)
        {
            if(!$_POST['qty'][$key] == '') array_push($_SESSION['pr'], filter_var($value, 
      FILTER_SANITIZE_SPECIAL_CHARS));
        }<br>
      }</p>
    
    <p>?></p>
  </blockquote>