Ich versuche jetzt seit einer ganzen Weile meine Array zu sortieren.
Also ich möchte, dass meine Arrays sortieren. Das sollte mit rsort() eigentlich funktionieren. Aber ich bekomme das irgenwie nicht hin. Das Script soll mir die Array-Zeile, welche die höchsten Votes hat als erstes anzeigen.
Mein php-Code:
Alles anzeigen
Meine Datentabelle ist wie folgt aufgebaut(eine Zeile);
TipTop,TipTop,111
Also ich möchte, dass meine Arrays sortieren. Das sollte mit rsort() eigentlich funktionieren. Aber ich bekomme das irgenwie nicht hin. Das Script soll mir die Array-Zeile, welche die höchsten Votes hat als erstes anzeigen.
Mein php-Code:
Quellcode
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <th width="25" bgcolor="#408040" scope="col"><div align="center"></div></th>
- <th bgcolor="#99CC99" scope="col"><div align="left"> Artist / Titel </div></th>
- <th width="100" bgcolor="#99CC99" scope="col"><div align="left">Votes</div></th>
- <th width="25" bgcolor="#99CC99" scope="col"><div align="center"></div></th>
- </tr>
- <?php
- $file_chart = "data/chart.mtd";
- $file_read = fopen("$file_chart","r");
- $line = 0;
- // Auslesen der Datei
- while (!feof($file_read))
- {
- $chart1 = fgets($file_read,64);
- list( $artist [] , $song [] , $votes []) = explode ( "," , $chart1 );?>
- <tr>
- <th width="25" bgcolor="#99CC99"><div align="center"><? echo $line++; ?></div></th>
- <td><div align="left"> <? echo $artist[1]; ?><br> <? echo $song[1]; ?></div></td>
- <td width="100"><div align="left"><? echo $votes[1]; ?></div></td>
- <td width="25"><div align="center"></div></td>
- </tr>
- <?
- }
- fclose($file_read);
- ?>
- </table>
Meine Datentabelle ist wie folgt aufgebaut(eine Zeile);
TipTop,TipTop,111