Reply to Re: Sorting

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация