[英]Find Array With 'SELECTED' Value Inside Multidimensional Array
I've got a very large JSON file that I've converted into an array. 我有一个非常大的JSON文件,已将其转换为数组。 The code you see below is the result of 您在下面看到的代码是
var_dump($array['talents'])
(for those wondering, yes, this is me attempting to use Blizzard Entertainment's API) (对于那些想知道的人,是的,这是我尝试使用暴雪娱乐公司的API)
Maybe I just missed that day at PHP school, but I just can't seem to remember or figure out how to get the values inside these deeper arrays. 也许我只是错过了那天在PHP学校的日子,但是我似乎不记得或想不出如何在这些更深层的数组中获取值。 And perhaps more importantly, pay attention to the two 'spec' fields - ONE of them has a value of 'SELECTED: BOOLEAN TRUE', and the other does not. 也许更重要的是,请注意两个“规范”字段-其中一个的值为“ SELECTED:BOOLEAN TRUE”,而另一个则没有。 Basically, I need the NAME field from the array that has that SELECTED value. 基本上,我需要具有SELECTED值的数组中的NAME字段。
To be honest, much as I love working in PHP, this multi-level thinking is a tad beyond me at the moment, I need some more experience. 老实说,就像我喜欢在PHP中工作一样,这种多层次的思考目前还远远超出了我,我需要更多的经验。 In the meantime, could anyone give me some tips, pointers, or just straight-up answers as to how I can get the value I need? 同时,有人可以给我一些技巧,指示或只是直接的答案,以告诉我如何获得所需的价值吗?
Thanks a bunch for your time! 感谢您的宝贵时间!
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)
should be 应该
print_r($array['talents'][0]);
print_r($array['glyphs']['major']);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.