1

I have this array from JSON file and I want to get data from [url]. Array is saved as variable $data.

stdClass Object
(
    [images] => Array
    (
            [0] => stdClass Object
            (
                    [startdate] => 20190625
                    [fullstartdate] => 201906250700
                    [enddate] => 20190626
                    [url] => /th?id=OHR.SutherlandFalls_ROW5711472757_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp
            )
    )
)

Result should be like:

echo $data[0]->url; will show the link/value /th?id=...
2
  • 2
    $data->images[0]->url Commented Jun 25, 2019 at 17:24
  • Thanks @Alex Howansky, couldn't figure it for hours. Commented Jun 25, 2019 at 17:26

1 Answer 1

1

Your $data variable is not an array, it's an instance of stdClass. Therefore, you can retrieve it like this:

$data->images[0]->url;
Sign up to request clarification or add additional context in comments.

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.