array_reverse()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hogl
    replied
    also ich hab jetzt nochmal den halben tag probiert, und komm einfach nicht auf die lösung. kann es sein das ich das array nochmal komplett neu sortieren muss?

    Leave a comment:


  • Hogl
    replied
    hier mal das ganze script :
    PHP Code:
    <h2 align=center>Tabelle</h2>
    <hr>
    <?php
    $file 
    file("list.txt");
    foreach(
    $file as $line)
    {
        
    $line chop($line);
        list(
    $punkte,$differenz,$score_plus,$score_minus,$niederlagen,$unentschieden,$siege,$spiele,$verein)=explode("|",$line);
        
    $liste[] = array((int)$punkte,$differenz,$score_plus,$score_minus,$niederlagen,$unentschieden,$siege,$spiele,$verein);
    }
    arsort ($liste);
    $x=0;

    foreach(
    $liste as $line)
    {
    $x++;
    $array1 = array($line[3]);
    $array2 array_reverse($array1);

        echo 
    '<div align="center">
                <table border="1" cellpadding="0" cellspacing="2" width="53%">
                    <tr>
                        <td width="20">
                            <div align="center">
                                '
    .$x.'</div>
                        </td>
                        <td width="250">
                            <div align="center">
                                '
    .$line[8].'</div>
                        </td>
                        <td width="30">
                            <div align="center">
                                '
    .$line[7].'</div>
                        </td>
                        <td width="30">
                            <div align="center">
                                '
    .$line[6].'</div>
                        </td>
                        <td width="30">
                            <div align="center">
                                '
    .$line[5].'</div>
                        </td>
                        <td width="30">
                            <div align="center">
                                '
    .$line[4].'</div>
                        </td>
                        <td width="55">
                            <div align="center">
                                '
    .$line[2].':'.implode($array2).':'.$line[3].'</div>
                        </td>
                        <td width="30">
                            <div align="center">
                                '
    .$line[1].'</div>
                        </td>
                        <td width="20">
                            <div align="center">
                                '
    .$line[0].'</div>
                        </td>
                    </tr>
                </table>
                </div>'
    ;
    }
    echo 
    '<div align="center"><br><br><font color="red" size="4"><b>! ! ! ! DER SCORE WIRD NOCH FALSCH SORTIERT ! ! ! !</font></b><hr></div>';
    ?>
    es wird alles von der größten zur kleinen zahl sortiert. nur eben bei score muss wenn der plus score leich ist, der miuns score eben zählen, und zwar der kleinere zuerst
    Last edited by Hogl; 30-11-2003, 21:27.

    Leave a comment:


  • mrhappiness
    replied
    mit deinem code erzeugst du ein array mit einem einzigen eintrag, nämlich dem wert von $line3

    was steht in $line[3] und wie soll's ausgegeben werden?
    hilft dir eventuell strrev weiter?

    Leave a comment:


  • Hogl
    replied
    es ist der 4.eintrag in jeder zeile meiner datei, aber ich wollte es ja mit
    PHP Code:
    $array1 = array($line[3]);
    $array2 array_reverse($array1); 
    zu einem array machen und dann quasi "umdrehen"

    Leave a comment:


  • mrhappiness
    replied
    ist $line[3] ein array oder die vierte zeile deiner datei list.txt?

    Leave a comment:


  • Hogl
    started a topic array_reverse()

    array_reverse()

    Hy all,

    folgendes script hab ich:
    PHP Code:
    $file file("list.txt");
    foreach(
    $file as $line)
    {
        
    $line chop($line);
        list(
    $punkte,$differenz,$score_plus,$score_minus,$niederlagen,$unentschieden,$siege,$spiele,$verein)=explode("|",$line);
        
    $liste[] = array((int)$punkte,$differenz,$score_plus,$score_minus,$niederlagen,$unentschieden,$siege,$spiele,$verein);
    }
    arsort ($liste);
    $x=0;

    foreach(
    $liste as $line)
    {
    $x++;
    $array1 = array($line[3]);
    $array2 array_reverse($array1); 
    jetzt muss ich die reihenfolge von $line[3] umdrehen. so wie es oben steht müsste es doch funktionieren, tut es aber nicht. Hat mir jemand n tip??

    Hogl
    Last edited by Hogl; 30-11-2003, 21:27.
Working...
X