自统计以来已经有一段时间了,所以我可能会离开这里 – 但这里有一个裂缝.
原文链接:https://www.f2er.com/php/133595.htmlfunction get_percentile($percentile,$array) { sort($array); $index = ($percentile/100) * count($array); if (floor($index) == $index) { $result = ($array[$index-1] + $array[$index])/2; } else { $result = $array[floor($index)]; } return $result; } $scores = array(22.3,32.4,12.1,54.6,76.8,87.3,45.5,87.9); echo get_percentile(75,$scores); echo get_percentile(90,$scores);