-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A little Help with async request #95
Comments
Well what is happening here is that the $kills = 0;
$onSuccess = function (Objects\MatchDto $match) use ($kills) {
foreach ($match->participants as $p)
if ($p->participantId==1 && $p->teamId==100)
$kills += $p->stats->kills;
};
// $onFailure = function ...
// foreach ($custom as $games) ...
// $api->commitAsync();
var_dump($kills);
echo "<br>"; This will aggregate the kills in the variable and after the commit is finished and all matches processed you print out the result. |
Hey @Lucasnl, the last missing piece of the puzzle is that Fully working snippet: $kills = 0;
$onSuccess = function (RiotAPI\LeagueAPI\Objects\MatchDto $match) use (&$kills) {
foreach ($match->participants as $p)
if ($p->participantId == 1 && $p->teamId == 100)
$kills += $p->stats->kills;
};
$onFailure = function ($ex) {
echo "Error occured: {$ex->getMessage()}\n";
};
foreach ($custom as $games) {
$api->nextAsync($onSuccess, $onFailure);
$match = $api->getMatch($games->match_id);
}
$api->commitAsync();
var_dump($kills); |
Thanks again for your time and help ! it worked very well |
im trying to get the sum of all kills from the participant id =1 , but it seems that array_sum is not working properly inside the $onsucess function , im getting only the kills for each match and not the sum of them all.
do you have any tips for me ?
im getting the kills from each game but the expected result is 122 , the sum of all those values
The text was updated successfully, but these errors were encountered: