Json response code:
Code: Select all
{
"response_code": 200,
"error": "",
"position": "Train has reached Destination and late by 5 minutes.",
"train_number": "12046",
"route": [
{
"no": 1,
"station": "CDG",
"has_arrived": false,
"has_departed": true,
"day": 0,
"distance": 0,
"scharr": "Source",
"schdep": "12:00",
"actarr": "00:00",
"actdep": "12:00",
"scharr_date": "19 Nov 2015",
"actarr_date": "19 Nov 2015",
"latemin": 0
},
{
"no": 2,
"station": "UMB",
"has_arrived": true,
"has_departed": true,
"day": 0,
"distance": 67,
"scharr": "12:40",
"schdep": "12:42",
"actarr": "12:40",
"actdep": "12:42",
"scharr_date": "19 Nov 2015",
"actarr_date": "19 Nov 2015",
"latemin": 0
}
]
}
Code: Select all
foreach($json ->route as $entry) //when the code executes i am getting the error here as trying to get property of non-object and invalid argument
{
echo $entry->station;
echo $entry->schdep;
}kindly help me to solve this problem