Sorry if this is a duplication of anyone elses question but in my eyes it doesn't appear to match any other PHP multi dimensional array questions on here. And I've read them all. :-(
I'm trying to access values of this array (which I have no control over). But it's format is puzzling me and as yet I can't get at the values how I thought I should be able to.
This my JSON array example.
{"Result":[{"Links":[{"UrlTo":"blahblahA/","Visited":1380104406,"FirstSeen":1375979058,"PrevVisited":1379817016,"Anchor":"text links","Type":"Text","Flag":[],"TextPre":"","TextPost":""}],"Index":0,"Rating":18.44400799929153,"UrlFrom":"blahblahB","IpFrom":"209.18.x.11","Title":"home page","LinksInternal":16,"LinksExternal":5,"Size":13107},{"Links":[{"UrlTo":"blahblahABC","Visited":1380574695,"FirstSeen":1375979100,"PrevVisited":1379224472,"Anchor":"text links","Type":"Text","Flag":[],"TextPre":"","TextPost":""}],"Index":1,"Rating":11.02675617091105,"UrlFrom":"blahblahXYZ","IpFrom":"209.18.x.11","Title":"Random title","LinksInternal":16,"LinksExternal":5,"Size":13107}]}
I naively thought that assigning this Json array to $arr Then decoding like so.
$arr = json_decode($str,true);
once done i could reference the array values like so...
$UrlTo = $arr['Result']['Links']['UrlTo'];
But I'm clearly not understanding this right. I've spent a lot of time googling, reading and still don't get it. I think it will be obvious to someone more experienced than I? Can someone help me understand the naivity of my approach.
print_r($arr)in your file to see the way the array is build$UrlTo = $arr['Result'][0]['Links'][0]['UrlTo'];?[]stands for an array.[{}]is an object inside an array.