views:

47

answers:

2

A Google APIs encoded in JSON returned an object such as this

[updated] => stdClass Object
(
 [$t] => 2010-08-18T19:17:42.026Z
)

Anyone knows how can I access the $t value?

$object->$t obviously returns

Notice: Undefined variable: t in /usr/local/... Fatal error: Cannot access empty property in /....

+7  A: 

This ought to work:

echo $object->{'$t'};

Failing that:

$property_name = '$t';
echo $object->{$property_name};
Jordan
+1 same answer as I had.
Brad F Jacobs
Thanks, this worked!
Flavio Copes
+1 And I thought I knew everything there is to know about PHP. Thanks for the education.
Byron Whitlock
+3  A: 

Have you tried:

$t = '$t'; // Single quotes are important.
$object->$t;
Macha
Worked too, thanks!
Flavio Copes