0

If I have an array in the following format:

Array ( [0] => stdClass Object ( [id] => 1 [c] => 1 [q] => value 1. ) [1] => stdClass Object ( [id] => 2 [c] => 1 [q] => value 2...

and I need to get

value 1

Shouldn't I be able to get it by doing something like?

$myArray[0]['q']

FOr some reason I'm not getting anything...

2 Answers 2

2

The element is inside an object, you need to do,

  echo $myArray[0]->q;
Sign up to request clarification or add additional context in comments.

Comments

2

You need to use $myArray[0]->q it is an object not an array.

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.