I have a JSON file that is causing me some trouble. It looks as follows.
process({
"www.google.com": {
"target": "google.com",
"0": [ 94, 70 ],
"1": [ 94, 70 ],
"2": [ 94, 70 ],
"4": [ 93, 66 ],
"categories": {
"501": 99,
"301": 48,
"304": 5
}
}
}
)
How would I go about echoing out the contents of "target" or "4" or "categories". I am rather new to JSON, but I have done my research and I am having no luck. Here is what I currently have.
<?php
$xml = file_get_contents('http://api.mywot.com/0.4/public_link_json2?hosts=http://www.google.com/&callback=process&key=*****');
//print_r($xml);
$json = json_decode($xml, true);
echo '<pre>' . print_r($xml, true) . '</pre>';
var_dump($json["www.google.com"]['target']);
You can see that I am getting the contents of my JSON from the mywot API. I am then printing it for testing purposes so I can see it. I just cant' access any of the individual elements in there. What am I doing wrong? The var_dump was just a test, but it returns NULL.