Here's my PHP code:
<?php
$json_url = "REDACTED";
$json = file_get_contents($json_url);
$stats = json_decode($json, true);
foreach ($stats as $row) {
echo $row['results']['result']['conversions'] . "<br />";
}
?>
Here's the JSON:
{
"metadata":{
"iserror":"false",
"responsetime":"0.07s"
},
"results":{
"first":1,
"last":99,
"total":99,
"result":[
{
"total_visitors":"3",
"visitors":"3",
"conversions":"0"
},
{
"total_visitors":"26",
"visitors":"26",
"conversions":"0"
},
{
"total_visitors":"13",
"visitors":"13",
"conversions":"0"
},
{
"total_visitors":"1",
"visitors":"1",
"conversions":"0"
},
{
"total_visitors":"1",
"visitors":"1",
"conversions":"0"
}
]
}
}
Essentially I'm just trying to echo the "conversions" from each section in the json file.
Never worked with a JSON file using PHP for, so I'm not really sure where I'm going wrong with this.