sorting a csv text file in PHP
| From: | Mike Mike | Date: | Mon, 12 Feb 2001 20:55:15 +0000 |
| Subject: | sorting a csv text file in PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-39262@lists.php.net to get a copy of this message | ||
Hi list,
I have a csv text file that looks like this:
Mike,1,Monday 12th of February 2001 02:14:09 PM
Bob,3,Monday 12th of February 2001 02:14:17 PM
Marry,2,Monday 12th of February 2001 02:16:38 PM
I'm trying to get it to sort by the 2nd value (number
descending and to show only the top two highest
scores:
Like this..
Bob,3,Monday 12th of February 2001 02:14:17 PM
Marry,2,Monday 12th of February 2001 02:16:38 PM
This is what I have for code now:
// show high scores
$lines = file("quiz.txt");
sort($lines);
for ($ i=0; $i < count ($lines); $i++){
$thisline = explode(",", $lines[$i]);
echo "<br>";
for($j=0; $j < count($thisline);$j++) {
echo "$thisline[$j]" ;
}
Is this possible to do?
I'm running linux with php3
Thank you
--Mike
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/