从PHP关联数组中获取值

时间:2014-06-22 03:27:11

标签: php arrays

我不确定如何遍历此数组以从第3个数组([0] =>数组)获取值。我如何获得leaguePoints的价值?

    Array
    (
[4605] => Array
    (
        [0] => Array
            (
                [name] => Hecarim's Duelists
                [tier] => DIAMOND
                [queue] => RANKED_SOLO_5x5
                [entries] => Array
                    (
                        [0] => Array
                            (
                                [playerOrTeamId] => 4605
                                [playerOrTeamName] => External
                                [division] => I
                                [leaguePoints] => 17
                                [wins] => 223
                                [isHotStreak] => 
                                [isVeteran] => 1
                                [isFreshBlood] => 
                                [isInactive] => 
                            )

                    )

            )

    )

)

2 个答案:

答案 0 :(得分:0)

这是5个嵌套数组。要获得leaguePoints,您需要使用与

类似的内容
echo $arr[4605][0]['entries'][0]['leaguePoints'];

答案 1 :(得分:0)

尝试获取数组的所有值

foreach($arr[4605][0]['entries'][0] as $v) { 
  echo $v;
} 

获取单一语句尝试

echo $arr[4605][0]['entries'][0]['leaguePoints'];