0
MONTHLY_PAYMENT: "9.7",
MAINTAINANCE_FEE: "20000",
areapoints: [
{
station: "大塚",
bus: null,
walking_distance: null
},
{
station: null,
bus: null,
walking_distance: null
},
{
station: null,
bus: null,
walking_distance: null
}
]

Getting the monthly payment and maintenance fee is easy, I just use $room->MONTHLY_PAYMENT.

But there is an arrayobject inside of the array which I am getting an error when I use $room->areapoints[0]->bus

This is the error:

Undefined property: ArrayObject::$bus

What am I doing wrong here

4

2 回答 2

1

您的属性$room->areapoints[0]->busnull您的列表语法中。因此,该属性不存在。

在使用它之前,您需要检查它是否存在:

if (isset($room->areapoints[0]->bus)) {
    // ... CODE HERE ...
}
于 2013-07-25T10:11:22.007 回答
0

更改$room->areapoints[0]->bus$room->areapoints[0]['bus']

于 2013-07-25T10:20:21.637 回答