JSON PHP DECODE HELP?

scott mardon

New member
I need to know the php code to retrieve the Distance element from the code below:

Distance":{"meters":11933,"html":"7.4\u0026nbsp;mi"}

i need the meters element. I only need the 11933 value

the json data is stored in an array $data which is json_decoded in php.

$json_o=json_decode($data);
$json_o->name; this shows the from:cf373ba to:CF434PG so i assume

$json_o->Distance should show the data i need but doesnt

Any help

Full code below

{"name":"from:cf373ba to:CF434PG","Status":{"code":200,"request":"directions"},"Placemark":[{"id":"","address":"Pontypridd, Mid Glamorgan CF37 3BA, UK","AddressDetails":{"Country":{"CountryNameCode":"GB","CountryName":"UK","AdministrativeArea":{"AdministrativeAreaName":"Mid Glamorgan","Locality":{"LocalityName":"Pontypridd","PostalCode":{"PostalCodeNumber":"CF37 3BA"}}}},"Accuracy": 5},"Point":{"coordinates":[-3.336051,51.620659,0]}},{"id":"","address":"Ferndale, Mid Glamorgan CF43 4PG, UK","AddressDetails":{"Country":{"CountryNameCode":"GB","CountryName":"UK","AdministrativeArea":{"AdministrativeAreaName":"Mid Glamorgan","Locality":{"LocalityName":"Ferndale","PostalCode":{"PostalCodeNumber":"CF43 4PG"}}}},"Accuracy": 5},"Point":{"coordinates":[-3.444665,51.665645,0]}}],"Directions":{"copyrightsHtml":"Map data \u0026#169;2010 Tele Atlas ","summaryHtml":"7.4\u0026nbsp;mi (about 18 mins)","Distance":{"meters":11933,"html":"7.4\u0026nbsp;mi"},"Duration":{"seconds":1090,"html":"18 mins"},"Routes":[{"Distance":{"meters":11933,"html":"7.4\u0026nbsp;mi"},"Duration":{"seconds":1090,"html":"18 mins"},"summaryHtml":"7.4\u0026nbsp;mi (about 18 mins)","Steps":[{"descriptionHtml":"Head \u003Cb\u003Enorthwest\u003C\/b\u003E on \u003Cb\u003EHigh View Way\u003C\/b\u003E","Distance":{"meters":88,"html":"289\u0026nbsp;ft"},"Duration":{"seconds":16,"html":"16 secs"},"Point":{"coordinates":[-3.335940,51.620780,0]}},{"descriptionHtml":"Take the 1st \u003Cb\u003Eright\u003C\/b\u003E toward \u003Cb\u003EGarth Ave\u003C\/b\u003E","Distance":{"meters":89,"html":"292\u0026nbsp;ft"},"Duration":{"seconds":26,"html":"26 secs"},"Point":{"coordinates":[-3.337160,51.620960,0]}},{"descriptionHtml":"Turn \u003Cb\u003Eleft\u003C\/b\u003E at \u003Cb\u003EGarth Ave\u003C\/b\u003E","Distance":{"meters":323,"html":"0.2\u0026nbsp;mi"},"Duration":{"seconds":43,"html":"43 secs"},"Point":{"coordinates":[-3.336720,51.621710,0]}},{"descriptionHtml":"Turn \u003Cb\u003Eleft\u003C\/b\u003E at \u003Cb\u003ECefn Ln\u003C\/b\u003E","Distance":{"meters":796,"html":"0.5\u0026nbsp;mi"},"Duration":{"seconds":73,"html":"1 min"},"Point":{"coordinates":[-3.340250,51.623360,0]}},{"descriptionHtml":"Take the 1st \u003Cb\u003Eright\u003C\/b\u003E onto \u003Cb\u003EDaren Ddu Rd\u003C\/b\u003E","Distance":{"meters":446,"html":"0.3\u0026nbsp;mi"},"Duration":{"seconds":45,"html":"45 secs"},"Point":{"coordinates":[-3.350230,51.622840,0]}},{"descriptionHtml":"Slight \u003Cb\u003Eright\u003C\/b\u003E to stay on \u003Cb\u003EDaren Ddu Rd\u003C\/b\u003E","Distance":{"meters":13,"html":"43\u0026nbsp;ft"},"Duration":{"seconds":14,"html":"14 secs"},"Point":{"coordinates":[-3.352420,51.626500,0]}},{"descriptionHtml":"Turn \u003Cb&#
 
Back
Top