我正试图获得每个学校的排名顺序已经按顺序排列。 例如,我想打印foreach循环之外的schoolToRank [0]的等级。 这是我的代码,通过成本,人口和顶尖成员获得所有学校的排名:
$rankedCost = setter_asc($test);
$rankedPopulation = setter_desc(setter_desc($user_selected_population));
$rankedTopN = setter_desc(setter_desc($user_selected_top));
$echo= '';
foreach($rankedCost as $school_toRank => $data){
echo '(school = '.$school_toRank . ' is rank = ' . $data['rank']. ')';
}
echo "<br>";
foreach($rankedPopulation as $school_toRank => $data){
echo '(school = '.$school_toRank . ' is rank = ' . $data['rank']. ')';
}
echo "<br>";
foreach($rankedTopN as $school_toRank => $data){
echo '(school = '.$school_toRank . ' is rank = ' . $data['rank']. ')';
}
因此,例如在学校2中,排名是1-如何单独访问它以仅显示具有该排名的学校(在foreach循环之外)?