View Full Version : How to parse best of stats.ini to tables

05-24-2004, 01:55 AM
]Hi guys great site you got here, im wondering if someone can give me a hand. im trying to set up stats for a game i play. i have a game that outputs stats to a file called stats.ini i want to take this data and put it in tables. i found out kinda how to do this but it takes everything! and i dont want everything i just want like the top 10 or something. here is the code im using now

<body bgcolor="#000000" text="#FF8a00">
// file() makes an array of each line of the file
$players = file("/home/council/public_html/stats/stats.ini");

echo "<table border=1 cellspacing=1 cellpadding=1>";

// loop through each line
foreach($players as $each){

// explode line into an array
$line = explode(",",$each);
echo "<tr><td>".$line[0]."</td><td>".$line[1]."</td><td>".$line[2]."</td></tr>\n";

echo "</table>";

and it displays this


here is the data file

if there is anyone that could help me it would be most appreciated.thanks

05-24-2004, 02:21 AM
I'm guessing that you have some sort of number for each player that you can decide which are the best 10 players!

If so i would make a file with fields like: [playername];[playerscore]

then compare the highest [playerscore] for each player (limit it to 10 using FOR loops, or others) and then display it.

05-24-2004, 02:33 AM
well the .ini file lists all the players then it lists kills then deaths and then it averages them and lists points. i just need a way to maybe insert these fields into a database or display the top points. when u click on that link all it does is display exactly what the stats.ini looks like.

im sorry im a noob with php so i dont know too many commands.

05-24-2004, 02:34 AM
can you post how an original file would look like?

05-24-2004, 05:15 AM
its like 2000 lines so i didnt post it here but the link is right here


05-24-2004, 05:25 AM
hey man i got this far


$line = file("C:\Inetpub\wwwroot\stats.ini");

echo "<table>
<tr><td>Player Name</td>
<td>Kills </td>
<td>Deaths </td>
<td>Points </td>

$name = $line[0+$i];
$name = substr($name, 9);

$kill = $line[500+$i];
$kill = substr($kill, 9);

$death = $line[1000+$i];
$death = substr($death, 10);

$points = $line[1000+$i];
$points = substr($points, 10);

echo "<tr><td>".$name."</td>



and it displays this but the problem is it only displays the top 10 lines not the highest ranking. it does good and puts the kills,deaths,points with the name but i need it to find the highest points and just display those names. if this needs a database thats not problem i just need help getting the code. thanks guys

Player Name Kills Deaths Points
KrazyYak[cov] 146 163 163
Player 0 1 1
Alien[CoV] 15 30 30
KrazyYak[covē] 164 122 122
[kod]bonebreaker[co] 17 35 35
MiLkNcOoKiEs[cov] 133 183 183
Dave 40 32 32
-=BH=-][*AchiLLeS*][ 20 13 13
xNSx_//_ForgottenOne 49 19 19
Lord_Hollowman 1 5 5