如何从这样解码的json响应中捕获变量?

时间:2019-01-26 07:15:41

标签: php arrays json

我在尝试从此类解码的json响应中捕获变量时遇到问题。

$response = json_decode($request); 

我有这样的答复:

    "request": {
        "contentType": "usual",
    },
    "result": [
        {
            "id": "001",
            "name": "test01",
            "parents": [
                {
                    "id": "1000000001",
                    "name": "test_parent_01",
                },
                {
                    "id": "2000000002",
                    "name": "test_parent_02",
                },
            ]
        }]

我需要以某种方式将这两个ID放入变量中:

  1. “ id”:“ 1000000001”
  2. “ id”:“ 2000000002”

所以,我需要$id1 = 1000000001 & $id2 = 2000000002

0 个答案:

没有答案
相关问题