PHP JSON检索对象值

时间:2016-04-08 02:13:34

标签: php json

我正在尝试从.json文件中获取所有对象。使用Core Data对象,我想获得其中唯一的项目。我无法获得stylerscolor

file.json

visibility

PHP代码:

[

  {
    "featureType": "road.highway",
    "elementType": "geometry.fill",
    "stylers": [
      { "color": "red" }
    ]
  }, {
    "featureType": "road.highway.controlled_access",
    "elementType": "geometry.fill",
    "stylers": [
      { "visibility": "off" }
    ]
  }, {
    "featureType": "poi.business",
    "elementType": "labels",
    "stylers": [
      { "visibility": "on" }

    ]
  }

]

1 个答案:

答案 0 :(得分:0)

$valuestdClass个对象。因此,要拨打colorvisibility,您需要:

echo $value->color;

echo $value->visibility;