Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下 JSON 对象:
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object] 0: Object category: Object 0: "Value"
我想知道如何在 PHP 中的变量中获取“值”。我认为 category[0] 会这样做,但我得到以下而不是“价值”:
__proto__: Object
我应该怎么办?
您必须将 JSON 字符串转换为关联数组,这由 json_decode() 完成,第二个参数设置为 true。
$var = json_decode($json, true); $value = $var['0']['category']['0'];