在PHP中解析JSON,并将每个值放入变量中

时间:2019-12-18 13:06:21

标签: php json

我有一个从API获取的JSON:

{
    "Meta Data": {
        "1. Information": "Weekly Prices (open, high, low, close) and Volumes",
        "2. Symbol": "ALUP11.SA",
        "3. Last Refreshed": "2019-12-17",
        "4. Time Zone": "US/Eastern"
    },
    "Weekly Time Series": {
        "2019-12-17": {
            "1. open": "27.2400",
            "2. high": "27.8000",
            "3. low": "26.9900",
            "4. close": "27.6300",
            "5. volume": "1505400"
        },
        "2019-12-13": {
            "1. open": "26.0900",
            "2. high": "27.3000",
            "3. low": "25.8800",
            "4. close": "27.0600",
            "5. volume": "3077100"
        },
        "2019-12-06": {
            "1. open": "26.1300",
            "2. high": "26.3700",
            "3. low": "25.7700",
            "4. close": "26.1500",
            "5. volume": "3842900"
        },
        "2019-11-29": {
            "1. open": "25.5500",
            "2. high": "26.1500",
            "3. low": "24.6900",
            "4. close": "26.0000",
            "5. volume": "4034000"
        },
        "2019-11-22": {
            "1. open": "24.1700",
            "2. high": "25.6800",
            "3. low": "23.4300",
            "4. close": "25.2600",
            "5. volume": "6119800"
        }
    }
}

我的疑问是:如何解析json以将值放入变量中以便持久存储在数据库中? 我需要的是“每周时间序列”中的每个日期以及该日期中的五个值。

0 个答案:

没有答案