title: How to make the summ (total) with php if there is more than one price?
body: <p>I'll make it simple, let's say i have a shopping cart, and three different prices:</p>
  
  <ol>
  <li>$price</li>
  <li>$specialprice</li>
  <li>$salesprice</li>
  </ol>
  
  <p>of course there are product quantities.</p>
  
  <p>The first step of math is:</p>
  
  <pre><code>&lt;?php
  
     $price_regular = $price * $quantity
     $price_special = $specialprice * $quantity
     $price_sales   = $salesprice * $quantity
  
  ?&gt;
  </code></pre>
  
  <p><strong>So let me make a simple example, after adding 3 products in cart:</strong></p>
  
  <ol>
  <li>Product A  - 30$ ($price)</li>
  <li>Product B  - 25$ ($specialprice)      (old price was 30$)</li>
  <li>Product C  - 22$ ($salesprice)        (old product was 35$)</li>
  </ol>
  
  <p>The summ shoud be 77$. </p>
  
  <p><strong>This is the result i want to get from my code.</strong></p>
  
  <p><strong>But HOW?</strong></p>
  
  <p>I tried doing smthing like:</p>
  
  <pre><code>&lt;?php
      $totalprice = $totalprice + $price_regular; 
  ?&gt;
  </code></pre>
  
  <p>but it only gives me the summ of REGULAR price. I need the code to calculate exactlly as in my simple example with product A - B - C</p>
  
  <p>This is the real code from my file:</p>
  
  <pre><code>$totalprice = 0;
                  $totalarticles = count($itemsonpage);
                  for ($i=0;$i&lt;=(count($itemsonpage) - 1);$i++){
                  $productslist[$i]['id'] = $itemsonpage[$i]['productid'];
                  $products-&gt;ShowByID($itemsonpage[$i]['productid']);
                  $productslist[$i]['code'] = $products-&gt;code;
                  $products-&gt;ShowLangDataByID($products-&gt;id,$chooselang);
                  $productslist[$i]['name'] = $products-&gt;name;
                  $productslist[$i]['quantity'] = $itemsonpage[$i]['quantity'];
                  $productslist[$i]['price'] = $itemsonpage[$i]['price'];
                  $productslist[$i]['specialprice'] = $products-&gt;specialprice;
                  $productslist[$i]['salesprice'] = $products-&gt;salesprice;
                  $productslist[$i]['allprice'] = $products-&gt;price * $productslist[$i]['quantity'];
                  $productslist[$i]['allprice2'] = $products-&gt;specialprice * $productslist[$i]['quantity'];
                  $productslist[$i]['allprice3'] = $products-&gt;salesprice * $productslist[$i]['quantity'];
  
  
                  $totalprice = $totalprice + $productslist[$i]['allprice'];
  </code></pre>