Jump to content

verdeandrea

Members
  • Posts

    123
  • Joined

  • Last visited

Community Answers

  1. verdeandrea's post in Rank position (with ties) was marked as the answer   
    It wasn't so hard in the end.
    I decided not to store the rank in the database, but just constructing it from the user points.
    I solved the problem of users with the same rank position in this way
    // I get the players pages and sort them by points $players = $users->find("sort=-user_points, sort=name"); // I explode the players into a scores array $scores = $players->explode("user_points"); // Using array_unique to remove duplicated scores $unique_scores = array_unique($scores); // With array_unique previous key are preserved so i need to create a new array with new keys $reindexed_scores = array_values($unique_scores); // I cycle through players foreach($players as $player) {  // I get the key of the user pointe in the array         $position = array_search($player->user_points, $reindexed_scores);         echo $position;         echo " - ";         echo $player;         echo " - ";         echo $player->user_points; } Hope this could help someone else with the same need.                    
     
×
×
  • Create New...