Answer the question
In order to leave comments, you need to log in
How to parse complex json in php?
Essence of the question:
We have a complex JSON of the form:
{
"Count":20,
"results": [
{"id":"1372", "idCat":"2", "Dev":"http://mysite.com",
"screenshot":["Link1", "Link2", "Link3"], "Url":"http://myappsite.com"},
{"id":"342", "idCat":"4", "Dev":"http://mysite2.com",
"screenshot":["Link1", "Link2", "Link3"], "Url":"http://myappsite2.com"},
{"id":"433", "idCat":"5", "Dev":"http://mysite3.com",
"screenshot":["Link1", "Link2", "Link3"], "Url":"http://myappsite3.com"}
]}
$j = file_get_contents($url_json_parse);
$data = json_decode($j);
print $data-> Count;
print $data->results->id[0];
Answer the question
In order to leave comments, you need to log in
$data->results[0]->id
In general, pass the second parameter true to json_decode() - it's easier to work with arrays.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question