Re: how to sum array items, vertically?
| From: | David Robley | Date: | Wed, 23 Jan 2002 08:40:43 +0000 |
| Subject: | Re: how to sum array items, vertically? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81655@lists.php.net to get a copy of this message | ||
sigurd@totallydigital.co.nz (Siggy) wrote in
news:20020123033332.86524.qmail@pb1.pair.com:
> Yeah, sorry, was posting late at night :P
>
> I am getting time-durations from a database, aggregating them per week
> (with a few conditions), so that I go from data like this:
>
> 2001-10-01, 4:30, 2 (ie, "person 2" did a "4 hour, 30 min"
> peice of work on a certain date).
>
> to this:
>
> date = hours work by person1, person2, person3, person4 ....
> 2001-01-01 = 23, 45, 12, 45, 02, as in:
>
> The reason i'm doing it in this way, is because I need to do a bit of
> shifting around of hours when people worked over midnight etc.
>
> Anyway, when I get to the end;
> 2001-01-01 = 23, 45, 12, 45, 02
> 2001-01-08 = 3, 15, 2, 35, 8
>
> etc etc ... I want to see the total (and the average, but thats easy)
> hours worked by each person.
>
> Siggy
>
> PS: Hey there New Zealander, hope you're in Wellington enjoying the
> positively fantastic weather :P
Nah, I'm in Auckland enjoying the weather without the wind :-) But only a
temporary Kiwi - Aussie underneath. Don't mention the cricket, OK?
From the looks of things, you should be able to use some sort of summing
and grouping, maybe a multiple query to pull the finished data out of your
DB, rather than struggling with multidimensional arrays?
--
David Robley
Temporary Kiwi!