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
  • 27,015
  • 29
  • 156
  • 295
Red Bottle
  • 2,839
  • 4
  • 22
  • 59

3 Answers3

2

Try this:

$myValue = $myObject->{1}->Product;
VirCom
  • 3,414
  • 1
  • 10
  • 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
  • 27,015
  • 29
  • 156
  • 295
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,846
  • 4
  • 34
  • 70