Problem with foreach loop

I have a loop:

foreach($_SESSION as $key => $val)
{ etc…

Then at the end i have a variable $dave which holds an integer value.

$dave = number_format($dave,2);
echo “€”.$dave." ".$valuenumber.“
n”; }

The problem is the variable $dave changes for each loop. I’m looking to get a total of all the $dave’s at the end. Does anyone have an idea how I’d do that? Does the variable name have to be changed each time or something?

Maybe you could make another variable, such as $total, and then at the end of the loop put $total += $dave;

Sponsor our Newsletter | Privacy Policy | Terms of Service