how can i get value from inside of function?
<p>Is it possible to get those values inside of function and use those outside of function
here is my code:</p>

<pre><code>&lt;?php
function cart() {
  foreach($_SESSION as $name =&gt; $value){
    if ($value&gt;0) {
      if (substr($name, 0, 5)=='cart_') {
        $id = substr($name, 5, (strlen($name)-5));
        $get = mysql_query('SELECT id, name, price FROM products WHERE id='.mysql_real_escape_string((int)$id));

        while ($get_row = mysql_fetch_assoc($get)) {
          $sub = $get_row['price']*$value;
          echo $get_row['name'].' x '.$value.' @ &amp;pound;'.number_format($get_row['price'], 2).' = &amp;pound;'.number_format($sub, 2).'&lt;a href="cart.php?remove='.$id.'"&gt;[-]&lt;/a&gt; &lt;a href="cart.php?add='.$id.'"&gt;[+]&lt;/a&gt; &lt;a href="cart.php?delete='.$id.'"&gt;[Delete]&lt;/a&gt;&lt;br /&gt;';
        }
      }      
      $total += $sub ;
    }
  }
}
?&gt;
</code></pre>

<p>now my question is how can  i get value of <code>$total</code>? 
i want to use that value out side fo function,
i have 2 function i cart and 1 discount
i tried return $total; (inside of function)
for example</p>

<pre><code>$final = cart () - discount ();
echo $final;
</code></pre>

<p>its echo out buth function echo code which r inside of function dont do any mathmatical operation.</p>
