Re: how to sum array items, vertically?

From: Date: Thu, 24 Jan 2002 01:28:41 +0000
Subject: Re: how to sum array items, vertically?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-81808@lists.php.net to get a copy of this message
Unfortunately I have to change and meddle with dates and times, so I can't. Siggy Format: The code is basically: $everything [ $date ] = array(10, 20, 30, 40); where $date is simply a text string like "01/01/2001"; Eg: array(4) { ["07/01/2002"]=> array(3) { [6]=> int(7200) [5]=> int(17400) [1]=> int(22500) } ["14/01/2002"]=> array(4) { [1]=> int(77400) [4]=> int(83700) [5]=> int(77400) [6]=> int(144300) } ["21/01/2002"]=> array(4) { [1]=> int(63900) [4]=> int(81900) [5]=> int(105000) [6]=> int(92400) } ["23/01/2002"]=> array(4) { [1]=> int(35100) [4]=> int(18000) [5]=> int(38100) [6]=> int(55500) } } Siggy "David Robley" <robleyd@paradise.net.nz> wrote in message news:Xns919FDCDCA9EB5robleydparadisenetnz@216.92.131.4... > 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!

« previous php.general (#81808) next »