Jump to content

Json N00B


chasethemetal

Recommended Posts

Hey all! Thanks again for the help on my earlier problems, much appreciated!!! I've got a new question dealing with json, as I am just beginning to fiddle with it! How would I echo out specific parts of this code in php? See json below. Thanks!!

 [{"people":[{"name":"bob","url":"http:\/\/www.bob.com","id":null}], "url":"http:\/\/www.site.com","status":"available","id":"1111111","datetime":null, "place": {"city":"Brooklyn","name":"Gallery","latitude":"40.7186480","region":"NY","country":"United States","url":"http:\/\/www.place.com","id":"222222","longitude":"-73.9602690"}, "datetime":"2012-01-28T20:00:00","t_url":"http:\/\/www.t.com/"}]

Link to comment
Share on other sites

Thanks. I've read that page, json_decode puts it into an array. But there are no examples on that page showing you how to get data that is as nested as the feed I'm getting. I f anyone could point me to a site that has examples where the data is similar to mine that would be great! Or show me a snippet here!

Link to comment
Share on other sites

have you tried using loops? That's most common technique of traversing arrays to get to their contents. for each level of nesting, you will need to use another loop. This unless you know specifically what you need in and the direct path to get to it.

Link to comment
Share on other sites

Well let me show you my confusion. Let see I'm trying to echo 'name' from my json list above... The json_encode($json, true) outputs this snippet..

 array(1) { [0]=> array(8) { ["people"]=> array(1) { [0]=> array(3) { ["name"]=> string(3) "bob" ["url"]=> string(19) "http://www.bob.com" ["id"]=> NULL } }

There more at the end... But just by looking at array examples and the such my logic tells me to do this (assume this is $arr). echo $arr[0]['people'][0]['name'];

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...