Forum Moderators: coopster

Message Too Old, No Replies

Need some help with "foreach".

Still learning but not understanding

         

IamStang

12:18 pm on May 8, 2005 (gmt 0)

10+ Year Member



I have been messing around with the use of "foreach". And have been able to take a list such as
Andy¦540¦August 24, 2004
Barb¦610¦January 3, 2005
Carl¦253¦December 14, 2004
and list them as
Andy scored 540 points on August 24, 2004.
Barb scored 610 points on January 3, 2005.
Carl scored 253 points on December 14, 2004.
Now, I am attempting to add the points from each individuals score for a total and not having a great deal of luck.

The data has been exploded into an array where $name = $tmp[0]; $score = $tmp[1]; and $date = $tmp[2];

Now, I just need someone to give me a clue as to how I go about getting a total of $score.

All help is appreciated.

Norky

12:32 pm on May 8, 2005 (gmt 0)

10+ Year Member



Create a new variable $totalscore, and in the foreach loop use

$totalscore += $score;

IamStang

11:28 pm on May 8, 2005 (gmt 0)

10+ Year Member



Thank you.

I havent tried it yet, but I am sure that should do the trick.

As it seems is always the case, I was trying to make it waaaayyyyy to difficult.