duanbu1421 2014-06-04 21:05
浏览 27
已采纳

PHP:获取包含此值的唯一数组

For the League of Legends API, I'm trying to get the players RankedSolo5x5. Successfully, I get that information for a player. But the array number will change depending on what players have & haven't played. So let's say RankedPremade5x5 has never been played. It won't appear in the array, thus making RankedSolo5x5 #4 instead of #5.

So instead of using this, which will only work if a user has that as the 5th class..

$soloSummonerRanked[5]->wins;

I'm trying to get the array by matching the value so that all these others arrays will not get in the way of what I'm trying to accomplish. Getting the number of wins in that specific game type. How can I do this?

[4] => stdClass Object
    (
        [playerStatSummaryType] => RankedPremade5x5
        [wins] => 0
        [losses] => 0
        [modifyDate] => 1347501723000
        [aggregatedStats] => stdClass Object
            (
            )

    )

[5] => stdClass Object
    (
        [playerStatSummaryType] => RankedSolo5x5
        [wins] => 203
        [losses] => 135
        [modifyDate] => 1401793988000
        [aggregatedStats] => stdClass Object
            (
                [totalChampionKills] => 3092
                [totalMinionKills] => 66904
                [totalTurretsKilled] => 649
                [totalNeutralMinionsKilled] => 8315
                [totalAssists] => 2471
            )

    )
  • 写回答

2条回答 默认 最新

  • doushi8186 2014-06-04 21:13
    关注

    You could fetch your array and check the playerStatSummaryType to see if it matches to RankedSolo5x5, and then get the wins.

    foreach($games_types as $type) {
    
      if($type->playerStatSummaryType == 'RankedSolo5x5') {
    
        $solo_wins = $type->wins;
        break;
      }
    }
    

    Anyway, better nerf Irelia !

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)