- var_dump: documentation ( source)
- json_decode: documentation ( source)
<?php
$str = ' {
"routes": [
{
"bounds": {
"northeast": {
"lat": 41.9291739,
"lng": 23.7293099
},
"southwest": {
"lat": 37.9103506,
"lng": 12.4822041
}
},
"copyrights": "Map data,google",
"legs": [
{
"distance": {
"text": "1,250 km",
"value": 1249958
}
}
]
}
]
}
';
$json = json_decode($str);
$distance = $json[routes][legs][distance][value];
var_dump($distance);