PHP ranks()

1 개요[ | ]

PHP ranks()
$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);
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]) );

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}