我有一个非常大的JSON文件,我已将其转换为数组。您在下面看到的代码是
的结果var_dump($array['talents'])
(对于那些想知道,是的,这是我试图使用暴雪娱乐的API)
也许我错过了那天在PHP学校,但我似乎无法记住或弄清楚如何在这些更深层的数组中获取值。也许更重要的是,要注意两个规范' fields - 其中一个的值为' SELECTED:BOOLEAN TRUE',另一个没有。基本上,我需要具有SELECTED值的数组中的NAME字段。
老实说,就像我喜欢用PHP工作一样,这种多层次的思维目前还有点超越我,我需要更多的经验。与此同时,任何人都可以给我一些提示,指示,或者只是直截了当地回答我如何获得我需要的价值吗?
非常感谢您的光临!
array (size=2)
0 =>
array (size=6)
'talents' =>
array (size=6)
0 =>
array (size=3)
...
1 =>
array (size=3)
...
2 =>
array (size=3)
...
3 =>
array (size=3)
...
4 =>
array (size=3)
...
5 =>
array (size=3)
...
'glyphs' =>
array (size=2)
'major' =>
array (size=0)
...
'minor' =>
array (size=1)
...
'spec' =>
array (size=6)
'name' => string 'Frost' (length=5)
'role' => string 'DPS' (length=3)
'backgroundImage' => string 'bg-mage-frost' (length=13)
'icon' => string 'spell_frost_frostbolt02' (length=23)
'description' => string 'Freezes enemies in their tracks and shatters them with Frost magic.' (length=67)
'order' => int 2
'calcTalent' => string '120021.' (length=7)
'calcSpec' => string 'b' (length=1)
'calcGlyph' => string 'O' (length=1)
1 =>
array (size=7)
'selected' => boolean true
'talents' =>
array (size=6)
0 =>
array (size=3)
...
1 =>
array (size=3)
...
2 =>
array (size=3)
...
3 =>
array (size=3)
...
4 =>
array (size=3)
...
5 =>
array (size=3)
...
'glyphs' =>
array (size=2)
'major' =>
array (size=0)
...
'minor' =>
array (size=0)
...
'spec' =>
array (size=6)
'name' => string 'Fire' (length=4)
'role' => string 'DPS' (length=3)
'backgroundImage' => string 'bg-mage-fire' (length=12)
'icon' => string 'spell_fire_firebolt02' (length=21)
'description' => string 'Ignite enemies with balls of fire and combustive flames.' (length=56)
'order' => int 1
'calcTalent' => string '122012.' (length=7)
'calcSpec' => string 'Z' (length=1)
'calcGlyph' => string '' (length=0)
答案 0 :(得分:0)
应该是
print_r($array['talents'][0]);
print_r($array['glyphs']['major']);