I must be loosing it this week. I forgot to test that the current count is not lower than the highest rnake already found
The code below should work, of course, you need to change the variable names to suit:
PHP Code:<?php
$post_count = 999;
$ranks = array('3000' => 'Power Poster',
'2000' => 'Addicted',
'1000' => 'Hyper',
'500' => 'Lively',
'100' => 'Member',
'0' => 'Noob');
$highest_rank = 0;
foreach($ranks as $count => $name) {
if (($post_count >= ((int) $count)) && ($count >= $highest_rank)) {
$highest_rank = $count;
}
}
echo($ranks[(string) $highest_rank]);
// vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4
?>





Reply With Quote