Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. $results = array("098"=>90,"099"=>89,"100"=>77,"101"=>77);
  2.  
  3. function getPosition($results,$StudentID){
  4. arsort($results);
  5.  
  6. $index = 1;
  7. $exists = '';
  8. $keys = array_keys($results);
  9.  
  10. foreach($keys as $key)
  11. {
  12. if($key == $StudentID)
  13. {
  14. $score = $results[$key];
  15. $position = $index;
  16. }
  17. $index++;
  18. }
  19. return $position;
  20.  
  21. }
  22. echo getPosition($results,"098").'<br />';
  23. echo getPosition($results,"099").'<br />';
  24. echo getPosition($results,"100").'<br />';
  25. echo getPosition($results,"101").'<br />';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement