Im busy with an chart of my Google Analytics.
I have made a JSON file with the dates and the visitors but now i got of each day of the year and I want to get the visitors each months.
Here is an example of the JSON results:
Dagindex,Gebruikers
1-1-2017,96
2-1-2017,116
3-1-2017,114
4-1-2017,101
5-1-2017,114
6-1-2017,111
7-1-2017,112
8-1-2017,96
9-1-2017,130
10-1-2017,123
11-1-2017,126
12-1-2017,116
13-1-2017,99
14-1-2017,88
15-1-2017,98
16-1-2017,150
17-1-2017,130
PHP Print_r() result:
Array
(
[0] => Array
(
[Dagindex] => 1-1-2017
[Gebruikers] => 96
)
[1] => Array
(
[Dagindex] => 2-1-2017
[Gebruikers] => 116
)
[2] => Array
(
[Dagindex] => 3-1-2017
[Gebruikers] => 114
)
[3] => Array
(
[Dagindex] => 4-1-2017
[Gebruikers] => 101
)
[4] => Array
(
[Dagindex] => 5-1-2017
[Gebruikers] => 114
)
[5] => Array
(
[Dagindex] => 6-1-2017
[Gebruikers] => 111
)
And what i want as result is like this:
01-2017 = XXXXX
02-2017 = XXXXX
03-2017 = XXXXX
till 12-2017 = XXXXX
Now i found this code below on stackoverflow, but i don't know how to change it for my results. Hope someone can help me out.
foreach($yourarray as $key=>$val){
$result[substr($key,0,7)] += $val;
}