1

I have an object which has multiple instances;

object(stdClass)#613 (5) {
  [0]=>
  object(stdClass)#426 (24) {
    ["created_at"]=>
    string(30) "Thu Jun 04 14:07:47 +0000 2015"
    ["id"]=>
     ...

I want to access a certain instance. I understand I can use a foreach or I can cast the object to an array and access the instance I want that way.

I also realise I should be able to access an instance using curly brace notation ( Server is running an old version of PHP - out of my control )

$tweets = retrieve_tweets();
if ( isset( $tweets{0}->created_at ) ) {
    ...

However I get the error;

Cannot use object of type stdClass as array

What am I doing wrong with this notation?

Community
  • 1
  • 1
myol
  • 8,857
  • 19
  • 82
  • 143

1 Answers1

0

I had to cast the object to an array in the end as the object properties had been named as integers...

Community
  • 1
  • 1
myol
  • 8,857
  • 19
  • 82
  • 143