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

2 Answers 2

1

Your property of $room->areapoints[0]->bus is null in your list syntax. Therefore, that property doesn't exist.

You need to check if it exists before using it with:

if (isset($room->areapoints[0]->bus)) {
    // ... CODE HERE ...
}
Sign up to request clarification or add additional context in comments.

1 Comment

My question is how to get the data inside, not how to handle nulls, but thanks anyway
0

Change $room->areapoints[0]->bus to $room->areapoints[0]['bus']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.