Looking for help in counting all values that are present in HTTP API. The link below outputs the values of multiple data points by date. What I am trying to achieve is a count on each value so that instead of
a:2:{s:10:"2018-01-03";a:9:{s:12:"nb_pageviews";d:2031;}s:10:"2018-01-04";a:9:{s:12:"nb_pageviews";d:25;}
I want to output the above nb_pageviews as a key with the value of the dates combined - 2056.
Example Link for API is https://demo.piwik.org/?module=API&method=Actions.get&idSite=7&period=day&date=last2&format=php&token_auth=anonymous
And the PHP to display this is
$url = "https://demo.piwik.org/";
$url .= "?module=API&method=Actions.get";
$url .= "&idSite=7&period=day&date=last2";
$url .= "&format=php";
$url .= "&token_auth=anonymous";
$fetched = file_get_contents($url);
$content = unserialize($fetched);
// case error
if (!$content) {
print("NO DATA");
}
foreach ($content as $row) {
$pageviews = $row['nb_pageviews'];
print("<div>$pageviews</div>
");
}
Please note that the above link contains multiple other values that I will be wanting to do the same with, yet for ensuring the readability of this question I have kept the values simple and to just the one.