Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input = "80 20 55 30 40 100";
- $data = explode(' ', $input);
- function rank($data){
- $result = [];
- foreach($data as $score){
- $upper = array_filter($data, function($i) use($score) {
- return $i > $score;
- });
- $result[] = count($upper)+1;
- }
- return $result;
- }
- echo implode(" ", rank($data));
Add Comment
Please, Sign In to add comment