PHP rank()

1 개요[ | ]

PHP rank()
function rank($value, $arr) {
	$sorted = $arr;
	rsort($sorted);
	$rank = array_search($value,$sorted);
	if($rank !== false ) return $rank+1;
	return false;
}
$arr = [79, 5, 18, 18, 32];
var_dump( rank(79, $arr) );
# int(1)
var_dump( rank(32, $arr) );
# int(2)
var_dump( rank(30, $arr) );
# bool(false)

2 같이 보기[ | ]

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