首页 > 解决方案 > 访问嵌套 JSON 参数

问题描述

我试图从 JSON 数组中获取 Vin 部分。

{
  "results": [
    {
      "vehicle": {
        "ownershipCondition": "Used",
        "registration": "BX68NHL",
        "vin": "ZFA3120000JA60541",
        "make": "Fiat",
        "model": "500",
        "generation": "Hatchback (2015 - )"
      }
    }
  ]
}

我尝试过使用它,但它不起作用。任何人都可以帮忙。

foreach($result['results'] as $res)
{
    $currCar = $res['vehicle']['vin'];
    echo $currCar."\n";
}

标签: phparraysjson

解决方案


推荐阅读