Skip to content

Instantly share code, notes, and snippets.

@skinofstars
Created June 26, 2012 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skinofstars/2995747 to your computer and use it in GitHub Desktop.
Save skinofstars/2995747 to your computer and use it in GitHub Desktop.
// we have two counters, so we can tie people while still incrementing the pos
$rank = 1;
$pos_count = 1;
// set the initial visit count
$visit_count = $leaderboard[0]['visit_count'];
foreach ($leaderboard as $lUser) {
if ($lUser['visit_count'] != $visit_count) {
$visit_count = $lUser['visit_count'];
$rank = $pos_count;
}
$leaderboard[$pos_count-1]['rank'] = $rank;
$pos_count++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment