访问php数组中的嵌套元素

时间:2019-03-07 17:42:26

标签: php arrays object for-loop

我有一个print_r的PHP对象,具有此结果

 fieldData: {},
portalData: {
    SubCategories: {
        0: {},
        1: {
            recordId: "3",
            SubCategories::SubCategoryName: "Multi-Channel",
            modId: "0"
    },
        2: {},
        3: {}
    }
},
recordId: "2",
modId: "3"

如何访问SubCategoryName?

1 个答案:

答案 0 :(得分:2)

您应该可以使用:

$object->portalData->SubCategories->{1}->{'SubCategories::SubCategoryName'} 

– Magnus Eriksson 2分钟前