0

I've JSON decoded a result from the CNET API and got the following (after var_dump()):

object(stdClass)#4 (35) { 
    ["Summary"]=> object(stdClass)#5 (1) { 
        ["$"]=> string(89) "Record keystrokes, visited web sites, and screenshots of all PC
activity in stealth mode."
    }
    ["Requirements"]=> object(stdClass)#6 (0) {}
    ["CNETContentIds"]=> object(stdClass)#7 (0) { } 
    ["CleverBridgeUrl"]=> object(stdClass)#8 (0) { } 
    ["BuyNowUrl"]=> object(stdClass)#9 (1) {
        ["@type"]=> string(0) "" 
    }
    ...

How do I access that 89-character string in the variable named "$"?

I've tried this:

$object->Summary->$

But my editor gave me an error.

I know, from trial and error that you can just string '->'s together to access nested objects, but it's so strange that a member is named $?

Even escaping the $ doesn't work:

$object->Summary->\$
Mark Baker
  • 205,174
  • 31
  • 336
  • 380
forgodsakehold
  • 577
  • 4
  • 11

2 Answers2

2

You can access non-standard property names with brackets {}:

$object->Summary->{'$'}
silkfire
  • 22,873
  • 14
  • 77
  • 98
0

Try;

$object->Summary->{'$'}

Or even

$object->{'Summary'}->{'$'}
Dom
  • 6,764
  • 1
  • 10
  • 13