|
Posted by Steve on 02/24/07 03:14
| >rsort($player_wins);
|
|
| I tried rsort, although it works but just for "$player_wins" but i need
to keep the association
| with $player_loss and $player_name since they're directly related to each
other.
|
| from my old basic language i remembered and use a double loop to get the
job done, but i know there
| is a much easier way. and thats why i'm asking.
well, that's where actually stating the requirements helps...rather than
assuming we can read minds. why not be smarter about the whole thing and not
magically assume that $i will always point to the same data in each
variable's array? gee, how about something like:
$stats = array();
for ($i = 0; $i < count($player_names); $i++)
{
$stats[$player_names[$i]] = array(
'WINS' => $player_wins[$i] ,
'LOSES' => $player_loss[$i] ,
'AVG' => $player_wins[$i] /
(
$player_wins[$i] +
$player_loss[$i]
)
)
}
now do your sorting. if you're about to bitch cuz i didn't show you how to
sort scores here, you truly are comatose. just cuz ur new doesn't mean you
can't think! that just may be a constant condition for you regardless of
experience...but, i digress.
[Back to original message]
|