1 개요[ | ]
- PHP ranks()
PHP
Copy
$arr = [79, 5, 18, 18, 32];
$sorted = $arr;
rsort($sorted);
$ranks = array_map(function($v) use ($sorted) { return array_search($v,$sorted)+1; },$arr);
print_r($ranks);
Loading
PHP
Copy
function ranks($arr) {
$sorted = $arr;
rsort($sorted);
return array_map(function($v) use ($sorted) { return array_search($v,$sorted)+1; },$arr);
}
print_r( ranks([79, 5, 18, 18, 32]) );
Loading
2 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.