Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2000071

[PHP] Re: [PHP-GENERAL] Trouble with sorting From: Richard Lynch (richard <email protected>)
Date: 07/01/00

In article <39596149.F77A12A7 <email protected>>, ildar <email protected> (Ildar
Akhmetov) wrote:

> Hello!
>
> I have two text files. One file, named 'players', contains names of
> soccer-players, next file, named 'votes', contains votes for each
> player. Strings numbers are same (#1 in players is #1 in votes, and so
> on).
>
> I need to diaplay a table with player ratings, sorted by rating. How can
> I do this?

This might do it...

<?php
  $players = file('/path/to/players') or die('could not find players file.');
  $votes = file('/path/to/votes') or die('could not find votes');
  rsort($votes);
  while (list($index, $votecount) = each($votes)){
    echo $players[$index], ": ", $votecount, "<BR>\n";
  }
?>

-- 
Richard Lynch                | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA        | http://www.L-I-E.com/artists.htm
http://www.zend.com          | (this has nothing to do with Zend, duh!)

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>