I have the following JSON response example (usually a long response):
"responseHeader":{
"status":0,
"QTime":2,
"params":{
"indent":"true",
"start":"0",
"q":"hi",
"wt":"json",
"rows":"2"}},
"response":{"numFound":69,"start":0,"docs":[
{
"id":335,
"Page":127,
"dartext":" John Said hi ! ",
"Part":1},
{
"id":17124,
"Page":127,
"Tartext":" Mark said hi ",
"Part":10}]
}}
I only want to access the property with the type of string the problem is the property's name is not constant so I can't use something like :
$obj =json_decode(file_get_contents($data));
$count = $obj->response->numFound;
for($i=0; $i<count($obj->response->docs); $i++){
echo $obj->response->docs[$i]->dartext;
}
because in the other object it's not dartext it's Tartext.
how can I access the third property by it's index not it's name ?