ausgabe nach Km sortieren lassen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • ausgabe nach Km sortieren lassen

    Ich möchte gerne den Parameter für KM Aufsteigend sortieren lassen.
    Leider funktioniert das so nicht.

    Code:
    preg_match_all("/{((track),(.*?),(.*?),(.*?))}/i", $acticon, $trackfund);
    $trackcount = 1;
    foreach ($trackfund[1] as $trackpara_komp) {
      $trackpara = explode(",", $trackpara_komp);
      
      sort ( $trackpara[2] ); // KM Sortieren
        
      // Sortieren  
      $trackcontent = "<div id=\"gpxtracks\">";
      $trackcontent .= "<a href=\"index.php?$getAnhang,$trackpara[3]\" title=\"Wegbeschreibung anzeigen\"> <b>$trackpara[1] - $trackpara[2]</b></a>";
      $trackcontent .= "</div>"; 
      
      $muster = "|{track,$trackpara[1],$trackpara[2],$trackpara[3]}|";
      $acticon = preg_replace($muster, $trackcontent, $acticon);
      $trackcount++;
      
    }

  • #2
    Entweder ist Dein Muster oder der Rest läuft falsch oder beides. Mal ein paar schnelle Beispiele:

    PHP-Code:
    <?php

    // Als Ziffern:

    $sortiere_1 = array(320133455224);
    sort($sortiere_1);

    echo 
    "Ausgabe sortiere_1:\n<pre>\n"print_r($sortiere_1); echo "</pre>\n";

    /* Ausgabe sortiere_1:

    Array
    (
        [0] => 133
        [1] => 224
        [2] => 320
        [3] => 455
    )
    */

    // Als Strings:

    $sortiere_2 = array("320""133""455""224");
    sort($sortiere_2);

    echo 
    "Ausgabe sortiere_2:\n<pre>\n"print_r($sortiere_2); echo "</pre>\n";

    /* Ausgabe sortiere_2:

    Array
    (
        [0] => 133
        [1] => 224
        [2] => 320
        [3] => 455
    )
    */

    $acticon "Wie weit ist es 320, 133, 455, 224 bis Berlin?";

    preg_match_all("/Wie weit ist es ([^,]+?),([^,]+?),([^,]+?),([^,]+?) bis Berlin/"$acticon$trackfund);

    echo 
    "Ausgabe print_r 1:\n<pre>\n"print_r($trackfund); echo "</pre>\n";       // Siehe: Ausgabe print_r 1

    $result array_merge($trackfund[1], $trackfund[2], $trackfund[3], $trackfund[4]);
    sort($result);

    echo 
    "Ausgabe print_r 2 ist sortiert:\n<pre>\n"print_r($result); echo "</pre>\n";  // Siehe: Ausgabe print_r 2

    /* Ausgabe print_r 1

    Array
    (
        [0] => Array
            (
                [0] => Wie weit ist es 320, 133, 455, 224 bis wohin
            )

        [1] => Array
            (
                [0] => 320
            )

        [2] => Array
            (
                [0] =>  133
            )

        [3] => Array
            (
                [0] =>  455
            )

        [4] => Array
            (
                [0] =>  224
            )
    )

    /* Ausgabe print_r 2 ist sortiert

    Array
    (
        [0] =>  133
        [1] =>  224
        [2] => 320
        [3] =>  455
    )
    */
    ?>

    Kommentar

    Lädt...
    X