2

I know it's probably a dumb question but I'm unable to go over this.

I have this Object array which looks like this

stdClass Object
(
[1] => stdClass Object
    (
        [Product] => Brand Manual
        [Type] => Custom
        [Width_(inches)] => 11
        [Depth_(inches)] => 8.5
        [Color_Type] => B/W
        [Artistic_Discretion] => Full Artistic Discretion(AD3)
        [Brief/Instructions] => edasd
         Product Dimension - 8.5" x 11"

        [Copy_Translation] => No
        [Additional_Versions] => 0
    )
 )

I want the Brand Manual so I do this $myValue = $myObject->1->Product; It doesn't work. The integer '1' seems to be the problem. I tried adding quotes too but it doesn't work either.Please help.

LF00
  • 24,667
  • 25
  • 136
  • 263
Red Bottle
  • 2,313
  • 4
  • 13
  • 40

3 Answers3

2

Try this:

$myValue = $myObject->{1}->Product;
VirCom
  • 2,546
  • 1
  • 9
  • 10
2

If your object variable is not cast from an array, you can access such properties with curly brace syntax.

$myObject->{'1'}->Product;

I strongly reconmend you read this great post

LF00
  • 24,667
  • 25
  • 136
  • 263
1

You have data stored in object format, so you should use object notation to get your specific data as

$myValue = $myObject->{1}->Product;
RAUSHAN KUMAR
  • 5,595
  • 4
  • 31
  • 65