0

i have $thisobject..

object(stdClass)#7 (4) {
  ["1"]=>
  object(stdClass)#8 (3) {
    ["id"]=>
    int(1)
    ["name"]=>
    string(9) "test1"
  }
  ["2"]=>
  object(stdClass)#9 (3) {
    ["id"]=>
    int(2)
    ["name"]=>
    string(7) "test2"
  }
  ["3"]=>
  object(stdClass)#10 (3) {
    ["id"]=>
    int(3)
    ["name"]=>
    string(7) "test3"
  }
  ["4"]=>
  object(stdClass)#11 (3) {
    ["id"]=>
    int(4)
    ["name"]=>
    string(8) "test4"
  }
}

why var_dump($thisobject->1) does not print the object inside?

it returns this error:

Parse error: syntax error, unexpected '1' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\dev\project\www\test.php on line 15

Rizier123
  • 58,877
  • 16
  • 101
  • 156
intrd
  • 27
  • 5

1 Answers1

0

Correct syntax to access object inside would be:

$thisobject->{'1'}