如何使用json_decode提取内部信息 [英] How to use json_decode to extract an inner information
本文介绍了如何使用json_decode提取内部信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是php新手.我需要json_decode/php的一些快速帮助.我需要在数组中获取g91的值,该怎么办?我想有一些递归值可以传递给json_decode ...
I am new to php. I need some quick help with json_decode/php. I need to get values of g91 in an array, how can I do this? I suppose there is some recursion value that we can pass to json_decode...
{
"e": "none",
"f": "test",
"g": [
{
"g1": "text2",
"g9": {
"text3": {
"g91": 0,
"g92": [
"text5"
]
}
}
},
{
"g1": "text1",
"g9": {
"text4": {
"g91": 0,
"g92": [
"text6",
"text7"
]
}
}
}
]
}
请注意,text3不是固定的.在下一条记录中,我有text4 ..
Please note that text3 is not fixed..in next record, I have text4..
谢谢!
推荐答案
将TRUE
作为第二个参数传递给json_decode
Pass TRUE
to json_decode as second parameter
$output = json_decode($input,TRUE);
比遍历数组.应该是这样的
Than traverse the arrays. It should be something like
$output['g'][0]['g9']['text3']['g91']
请参考 json_decode
这篇关于如何使用json_decode提取内部信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文