On 8/2/12 05:51, "Paul Halliday" <paul.halliday@xxxxxxxxx> wrote: >What I have is an array of values and timestamps: > >17 15:31 >16 15:32 >27 15:33 >14 15:34 >11 15:35 > >now for a day I should have 1440 entries but there could be spotty >results, no data from say 11:59 -> 13:00. >What I need is to sum the values for each hour interval. I may be misinterpreting what you're asking, but what about something like this: $times = array( 17 => '15:31', 16 => '15:32', 27 => '15:33', 14 => '15:34', 11 => '15:35', 27 => '16:33', 14 => '17:34', 11 => '11:35', 11 => '11:36', ); $sums = array_fill(0, 24, 0); foreach ($times as $value => $time) { $sums[substr($time, 0, 2)] += (integer)$value; } print_r($sums); This produces: /usr/bin/php /Volumes/Dev/Sites/playground/play4.php Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 11 [12] => 0 [13] => 0 [14] => 0 [15] => 33 [16] => 27 [17] => 14 [18] => 0 [19] => 0 [20] => 0 [21] => 0 [22] => 0 [23] => 0 ) Process finished with exit code 0 -- Robert E. Williams, Jr. Associate Vice President of Software Development Newtek Businesss Services, Inc. -- The Small Business Authority https://www.newtekreferrals.com/rewjr http://www.thesba.com/ Notice: This communication, including attachments, may contain information that is confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If the reader or recipient of this communication is not the intended recipient, an employee or agent of the intended recipient who is responsible for delivering it to the intended recipient, or if you believe that you have received this communication in error, please notify the sender immediately by return e-mail and promptly delete this e-mail, including attachments without reading or saving them in any manner. The unauthorized use, dissemination, distribution, or reproduction of this e-mail, including attachments, is prohibited and may be unlawful. If you have received this email in error, please notify us immediately by e-mail or telephone and delete the e-mail and the attachments (if any). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php