I am working on a statistics application and I want to output the amount of interactions that happened by day.
I have an multidimensional array that pulls all the information from the database, here is an example:
[0] => Array
(
[date] => 2012-07-26
[location] => 709c6d241674ca22
[action] => start_scan
)
[1] => Array
(
[date] => 2012-07-26
[location] => 709c6d241674ca22
[action] => scan_displayed
)
[2] => Array
(
[date] => 2012-07-27
[location] => 709c6d241674ca22
[action] => lower_device
)
[3] => Array
(
[date] => 2012-07-27
[location] => 709c6d241674ca22
[action] => how_to_use_displayed
)
[4] => Array
(
[date] => 2012-07-27
[location] => 709c6d241674ca22
[action] => raise_device
)
[5] => Array
(
[date] => 2012-07-28
[location] => 709c6d241674ca22
[action] => scan_displayed
)
I can work out what day each interaction occurred on by formatting the date:
date('D', strtotime('2012-07-26'));
My question is how do I count how many interactions happened on each day of the week and then output it, something like:
[Sunday] => 2
[Monday] => 3
[Tueday] => 1
[Wednesday] => 5
[Thursday] => 10
[Friday] => 4
[Saturday] => 9
Any suggestions are really appreciated!
You may want to declare the array as $dates = array(‘Monday’=>0, ‘Tuesday’=>0 …. ) to get the array containing the days with no interactions.