I’m a newbie with PHP so this might be ridiculously easy question, but despite my brave googling attempts I didn’t get it sorted out.
I’ve got an array called $report that looks like this when rendered with print_r:
Array
(
[] => Array
(
[ga:pageviews] => 272
[ga:visits] => 90
)
)
It’s created by the googleanalytics.class.php from the XML response. But I fail to extract specific value from it. Using $report[0][0] or $report[0][‘ga:pageviews’] returns nothing to me.
I also tried to iterate through it with foreach loop but failed to dig into it. I’m sure this is something super simple, but after few hours of banging my head I hope someone can ease my pain how to extract the pageview and visit values from it.
Thanks in advance!
This should work
echo $report[0]["ga:pageviews"];To iterate just use a double
foreach