I am currently playing with Riot Games API and using one of the wrappers developed by the community (https://github.com/kevinohashi/php-riot-api). My issue is, I am trying to sort the results using arsort
My code example:
<?php
include('php-riot-api.php');
$summoner_name = 'fallingmoon';
$summoner_id = 24381045;
$test = new riotapi('euw');
$r = $test->getLeague($summoner_id);
?>
<?php
$array = json_decode($r, true);
foreach($array AS $key => $newArray) {
$tempArray[$key] = $newArray['entries'][0]['leaguePoints'];
}
arsort($tempArray);
$finalArray = array();
foreach($tempArray AS $key => $value) {
$finalArray[] = $array[$key];
}
?>
My goal is sort the array by league points (Highest to lowest), but the output of the array once I print it is as followed, as you can see it hasn't sorted. I am probably missing something very minor but any help will be greatly appreciated.
Array
(
[0] => Array
(
[name] => Rengar's Demolishers
[tier] => GOLD
[queue] => RANKED_SOLO_5x5
[entries] => Array
(
[0] => Array
(
[playerOrTeamId] => 33372844
[playerOrTeamName] => L3tsPl4yLoL
[leagueName] => Rengar's Demolishers
[queueType] => RANKED_SOLO_5x5
[tier] => GOLD
[rank] => V
[leaguePoints] => 0
[wins] => 34
[isHotStreak] => 1
[isVeteran] =>
[isFreshBlood] =>
[isInactive] =>
[lastPlayed] => -1
)
[1] => Array
(
[playerOrTeamId] => 19397582
[playerOrTeamName] => Lunchi
[leagueName] => Rengar's Demolishers
[queueType] => RANKED_SOLO_5x5
[tier] => GOLD
[rank] => IV
[leaguePoints] => 10
[wins] => 7
[isHotStreak] =>
[isVeteran] =>
[isFreshBlood] =>
[isInactive] =>
[lastPlayed] => -1
)
[2] => Array
(
[playerOrTeamId] => 24613501
[playerOrTeamName] => RadiantBurst
[leagueName] => Rengar's Demolishers
[queueType] => RANKED_SOLO_5x5
[tier] => GOLD
[rank] => II
[leaguePoints] => 42
[wins] => 48
[isHotStreak] =>
[isVeteran] =>
[isFreshBlood] =>
[isInactive] =>
[lastPlayed] => -1
)
[3] => Array
(
[playerOrTeamId] => 19939979
[playerOrTeamName] => vinter
[leagueName] => Rengar's Demolishers
[queueType] => RANKED_SOLO_5x5
[tier] => GOLD
[rank] => I
[leaguePoints] => 38
[wins] => 57
[isHotStreak] =>
[isVeteran] =>
[isFreshBlood] =>
[isInactive] =>
[lastPlayed] => -1
)
$tempArray
look like? – Nouphal.M Mar 3 at 16:45