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
  • 209,507
  • 32
  • 346
  • 385
forgodsakehold
  • 870
  • 10
  • 26

2 Answers2

2

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

$object->Summary->{'$'}
silkfire
  • 24,585
  • 15
  • 82
  • 105
0

Try;

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

Or even

$object->{'Summary'}->{'$'}
Dom
  • 7,135
  • 1
  • 11
  • 13