1

I have a vardump that looks like this:

Array
(
    [0] => stdClass Object
        (
            [downloadsLeft] => 0
        )

)

It's stored in the variable $downloadsOBJ

How would I access the downloadsLeft variable within that array and store it in a new variable:

e.g.

$downloadsLeft = $downloadsOBJ['downloadsLeft'];

2 Answers 2

6

$downloadsLeft = $downloadsOBJ[0]->downloadsLeft; should do the trick

Sign up to request clarification or add additional context in comments.

Comments

5

I believe $downloadsLeft = $downloadsOBJ[0]->downloadsLeft; because stdClass is an object, not an array..

2 Comments

$downloadsOBJ itself is an array.
Haha, oops, my bad. Thanks for catching that.

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.