this is my json object
object(stdClass)#23 (2) { ["type"]=> string(4) "text" ["$t"]=> string(10) "cippalippa" }
How can I access to "text" ["$t"]
?
Solved with this string: $obj->{'$t'}
You need to escape the dollar sign:
echo $object["\$t"];
$object = json_decode({ ["type"]=> string(4) "text" ["$t"]=> string(10) "cippalippa" });
echo $objetct->$t;
Is this working?
You need to use this syntax:
$object->{'$t'}
The other two that were mentioned here don’t work as:
– an object is not an array$object["\$t"]
– this would be interpreted as a variable variable:$objetct->$t
[…] if you have an expression such as
$foo->$bar
, then the local scope will be examined for$bar
and its value will be used as the name of the property of$foo
.