Also ich will mit fgetcsv eine datei laden und dann nach einer bestimmten spalte sortieren lassen aber irgendwie schmeisst er mir alles durch einander.
hier mal der code
<?php require_once ('config.php'); //How many rows of results would you like? (ex. Enter "10" for Top 10 $limitresults=10; //How many characters long would you like each string before its replaced with "..." $trunication=30; //Location of your mani_ranks.txt file. //It can be a URL or a direct link to the file //(i.e. //http://server.com/mani_ranks.txt or data/mani_ranks.txt $manirankslocation="ftp://$user:$pass@$ftp_server/server/css23015/cstrike/cfg/mani_admin_plugin/data/mani_ranks.txt"; $handle = fopen($manirankslocation, "r"); function compare ($x, $y) { if ($x[29] == $y[29]) return 0; else if ($x[29] < $y[29]) return -1; else return 1; } $row = 0; while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) { $num = count($data); usort($data, 'compare'); $row_color = ($row % 2) ? $bgcolor2 : $bgcolor1; if($row < $limitresults){ if(strlen($data[64]) > $trunication){ echo "<tr> <td bgcolor='$row_color'>" . $data[3]. "</td>"; echo "<td bgcolor='$row_color'>" . $data[64]. "</td>"; echo "<td bgcolor='$row_color'>" . $data[29] . " </td>"; echo "<td bgcolor='$row_color'>" . $data[4]. "</td></tr>"; }else{ echo "<tr> <td bgcolor='$row_color'>" . $data[3] . "</td>"; echo "<td bgcolor='$row_color'>" . $data[64]. "</td>"; echo "<td bgcolor='$row_color'>" . $data[29] . "</td>"; echo "<td bgcolor='$row_color'>" . $data[4]. "</td></tr>"; } } $row++; } fclose($handle); ?>
Hat einer einen Tip für mich?
Mfg Skared
verwendete ilchClan Version: 1.1
betroffene Homepage: externer Link