我有以下数组,我想选择数组的等级和等级,其中queueType等于RANKED_FLEX_TT 或RANKED_SOLO_5x5或RANKED_FLEX_SR。我该怎么做呢?我无法执行以下操作来选择RANKED_SOLO_5x5,因为数组是随机显示的。也就是说有时queueType RANKED_SOLO_5x5将在数组[1]或数组[2]中,而不是总是在数组[0]中。所以我不能简单地这样做来找到queueType等于RANKED_SOLO_5x5的层和等级:
<?php echo $r1[0]["tier"].' '.$r1[0]["rank"]; ?>
以下是数组的示例:
Array
(
[0] => Array
(
[leagueName] => Anivia's Hunters
[tier] => GOLD
[queueType] => RANKED_SOLO_5x5
[rank] => IV
[playerOrTeamId] => 19302018
[playerOrTeamName] => AlLeXaNDeR
[leaguePoints] => 55
[wins] => 198
[losses] => 185
[veteran] => 1
[inactive] =>
[freshBlood] =>
[hotStreak] =>
)
[1] => Array
(
[leagueName] => Yorick's Warmongers
[tier] => GOLD
[queueType] => RANKED_FLEX_TT
[rank] => V
[playerOrTeamId] => 19302018
[playerOrTeamName] => AlLeXaNDeR
[leaguePoints] => 0
[wins] => 21
[losses] => 13
[veteran] =>
[inactive] =>
[freshBlood] => 1
[hotStreak] =>
)
[2] => Array
(
[leagueName] => Yorick's Rageborn
[tier] => SILVER
[queueType] => RANKED_FLEX_SR
[rank] => II
[playerOrTeamId] => 19302018
[playerOrTeamName] => AlLeXaNDeR
[leaguePoints] => 100
[wins] => 61
[losses] => 56
[veteran] => 1
[inactive] =>
[freshBlood] =>
[hotStreak] =>
[miniSeries] => Array
(
[target] => 2
[wins] => 1
[losses] => 1
[progress] => LWN
)
)
)
答案 0 :(得分:1)
希望能帮到你:
foreach($array as $subArray){
foreach($subArray as $key => $value){
if($key === "queueType" and ($value === "RANKED_FLEX_TT" or $value === "RANKED_SOLO_5x5" or $value === "RANKED_FLEX_SR"))
echo $item['tier'] . ' ' . $item['rank'] . '<br>';
}
}