1

this is my json object

object(stdClass)#23 (2) { ["type"]=> string(4) "text" ["$t"]=> string(10) "cippalippa" } 

How can I access to "text" ["$t"] ?

1
  • What are you wanting access to? 'text' or [$t] Commented Feb 8, 2012 at 11:41

4 Answers 4

5

You need to use this syntax:

$object->{'$t'}

The other two that were mentioned here don’t work as:

  • $object["\$t"] – an object is not an array

  • $objetct->$t – this would be interpreted as a variable variable:

    […] 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.

Sign up to request clarification or add additional context in comments.

Comments

1

You need to escape the dollar sign:

echo $object["\$t"];

Comments

1
$object = json_decode({ ["type"]=> string(4) "text" ["$t"]=> string(10) "cippalippa" });

echo $objetct->$t;

Is this working?

Comments

0

Solved with this string: $obj->{'$t'}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.