I have implemented in my game an online score system via FTP. Here, take a look at the text file that gets updated :
User0:1000
User1:1500
User2:250
User3:700
Then, what I'd do is creating a table that has 3 columns : Rank | Name | Score
I was already able to extract the name and the score for each individual line :
<table><td>Rank</td><td>Name</td><td>Score</td>
<?php $lines = file("./scores/pk.txt");
for($i=0;$i<count($lines);$i++) {
echo "<tr><td></td>";
echo "<td>".substr($lines[$i],0,strpos($lines[$i],":"))."</td>";
echo "<td>".substr($lines[$i],strpos($lines[$i],":")+1)."</td>";
echo "</tr>";
} ?> </table<
But you know, if I execute this, I get the first column empty (because of the "<td></td>").
So my question is (finally) :
How to sort this array by third column and assigning the right rank in the first column ?
In my example it would look like :
Rank | Name | Score
1 | User1 | 1500
2 | User0 | 1000
3 | User3 | 700
4 | User2 | 250
<td></td>always use<td> </td>the non-breaking space will make the cell actually show