0

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 Answers 2

1

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 !

Sign up to request clarification or add additional context in comments.

1 Comment

Yes! It simplified so easily and I was able to use it for more than one game type of course. I really appreciate that! :D They should nerf my boy Nasus, went 27/4 last night. haha
0
$winsRankedSolo5x5 = NULL;

foreach($soloSummonerRanked as $rank) {
  if($rank->playerStatSummaryType == 'RankedSolo5x5') {
    $winsRankedSolo5x5 = $rank->wins;
    break;
  }
}

basically you cycle through each element of the array looking for the one whose stat type is RankedSolo5x5 and, when you find it, you can get the wins and do whatever you want with it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.