find php group by using an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vishnu22_7
Forum Newbie
Posts: 2
Joined: Fri Mar 11, 2011 7:01 am

find php group by using an array

Post by vishnu22_7 »

I have the php array like this:

Code: Select all

Array
(
    [0] => Array
        (            
            [time_stamp] => 1287484988
            [date_time] => Tuesday, 19 October 2010 16:13:7
            [day] => 19
            [month] => 10
            [year] => 2010
            [time_spent] => 41
        )

    [1] => Array
        (         
            [time_stamp] => 1287484662
            [date_time] => Tuesday, 19 October 2010 16:7:41
            [day] => 19
            [month] => 10
            [year] => 2010
            [time_spent] => 215           
        )
)
I calculated the number of days in a given month like this:

Code: Select all

$num_days = cal_days_in_month(CAL_GREGORIAN, $month, $year);   
How do i loop through the "$num_days" to calculate the SUM of time_spent using GROUP BY time_stamp where day=$day,month=$month,year=$year

Thank u.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: find php group by using an array

Post by social_experiment »

Code: Select all

<?php
print_r($num_days);
?>
What is echoed to the browser when you do this?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
vishnu22_7
Forum Newbie
Posts: 2
Joined: Fri Mar 11, 2011 7:01 am

Re: find php group by using an array

Post by vishnu22_7 »

$num_days is total number of days in a goven month: for Jan, it is 31
Post Reply