我已将一个JSON文件解码为一个变量($tmp
)。 var_dump($tmp)
给出:Php和JSON:对象(stdClass)
object(stdClass)#31 (3) {
["c"]=> int(2)
["r"]=> int(2)
["d"]=> object(stdClass)#32 (4) {
["1"]=> string(2) "un"
["2"]=> string(4) "deux"
["3"]=> string(5) "trois"
["4"]=> string(6) "quatre"
}
}
我想检索例如“UN”所以我做$tmp->d["1"]
,但它不工作。我有以下错误:
Fatal error: Cannot use object of type stdClass as array in File.php on line 17
可能重复的[不能使用stdClass类型的对象作为数组吗?](http://stackoverflow.com/questions/6815520/cannot-use-object-of-type-stdclass-as-array) – hakre 2013-05-02 16:07:33