functions.php 1.1 KB

12345678910111213141516171819202122232425262728
  1. <?php
  2. function print_player_list($player_list,$players,$playersmax)
  3. {
  4. $data = "<table class='player_monitor' style='border:none;'><thead>";
  5. $data .= "<tr><th>".get_lang('player_name')."</th><th>".get_lang('score')."</th><th>".get_lang('time')."</th></tr>";
  6. $data .= "</thead><tbody>";
  7. foreach ($player_list as $key => $row) {
  8. $name[$key] = $row['name'];
  9. $score[$key] = $row['score'];
  10. $time[$key] = $row['time'];
  11. }
  12. //Sort by score, the 1st position in this array multisort, score, defines the row that sorts the array, if there are two equal scores then the next row, time, will sort this array.
  13. array_multisort($score, SORT_DESC,
  14. $time,
  15. $name, $player_list);
  16. $i = 0;
  17. foreach( $player_list as $player ){
  18. $data .= "<tr";
  19. if($i%2 == 0) $data .= 'class="odd"';
  20. $data .="><td>".htmlentities(@$player['name'])."</td><td>".@$player['score']."</td><td>".@$player['time']."</td></tr>";
  21. $i++;
  22. }
  23. $data .= "</tbody><tfooter><tr><td colspan='3'>".get_lang('players').": " . $players."/".$playersmax . "</td></tr>";
  24. $data .= "</tfooter></table>";
  25. return $data;
  26. }
  27. ?>