如何使用PHP读取此JSON? [英] How to read this JSON using PHP?

查看:108
本文介绍了如何使用PHP读取此JSON?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JSON格式的新手,在阅读的教程中,我不太了解如何使用php进行解析.所以我有这个:

I'm very new with JSON format, and in the tutorials I read I don't understand well how to parsed using php. So I have this:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -67.593742,
                    10.24462
                ]
            },
            "properties": {
                "id": "669163449",
                "accuracyInMeters": 0,
                "timeStamp": 1301841780,
                "reverseGeocode": "Maracay, Venezuela",
                "photoUrl": "https://www.google.com/latitude/apps/badge/api?type=photo&photo=Df7VGy8BAAA.9of56owsf4wI6F4odEQ",
                "photoWidth": 96,
                "photoHeight": 96,
                "placardUrl": "https://g=true&stale=false&lod=4&format=png",
                "placardWidth": 56,
                "placardHeight": 59
            }
        }
    ]
}

我想回显坐标 reverseGeocode .有人可以请我朝正确的方向前进吗?

And I want to echo coordinates and reverseGeocode. Can anyone please put me in the right direction?

推荐答案

尝试运行

$decoded = json_decode($json_string, true);
print_r($decoded);
print_r($decoded["features"][0]["geometry"]["coordinates"]);
echo $decoded["features"][0]["properties"]["reverseGeocode"];

其中$json_string是您的示例JSON(作为字符串).

where $json_string is your sample JSON as a string.

这篇关于如何使用PHP读取此JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆