Sortieren (n-Array)

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

  • #31
    Ebenfalls nciht

    Kommentar


    • #32
      Ebenfalls nciht
      Codeausschnitt bitte...
      Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

      [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
      Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

      Kommentar


      • #33
        PHP-Code:
            function getStructure($customerid$folderid) {
                global 
        $db$common$customer;
                
                
        $customerid $customer->returnIntegerID($customerid);
                
                
        $res $db->query("SELECT `documentFolderID`, `documentFolderName`
                FROM `documentFolder`
                WHERE `documentFolderParent` = '"
        .$folderid."'
                AND `documentFolderCustomer` = '"
        .$customerid."'");
                
                
        $i 0;
                while(
        $row mysql_fetch_assoc($res)) {
                    
                    
        $tmp[] = array("id" => $row["documentFolderID"], "type" => "folder""name" => $row["documentFolderName"]);
                    
                }
                
                
        $res $db->query("SELECT `documentFileID`, `documentFileName`
                FROM `documentFile`
                WHERE `documentFileFolder` = '"
        .$folderid."'
                AND `documentFileCustomer` = '"
        .$customerid."'");
                
                while(
        $row mysql_fetch_assoc($res)) {
                    
                    
        $tmp[] = array("id" => $row["documentFileID"], "type" => "file""name" => $row["documentFileName"]);
                    
                }
                
                
        $sortTmp = array();
                
                foreach(
        $tmp as $key => $value) {
                    
        $sortTmp[$key] = $value["name"];
                }
                        
                
        usort($sortTmp"cmp");

                
        array_multisort($sortTmpSORT_ASCSORT_STRING$tmp);
                
                return 
        $tmp;
                
            } 
        Die Funktion cmp ist von TobiaZ vorhanden!

        Kommentar


        • #34
          Die Funktion cmp ist von TobiaZ vorhanden!
          Und wo ist diese definiert ? Vor oder nach deiner getStructure() ? Btw ist dein error_reporting() überhaupt voll aufgedreht ?
          Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

          [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
          Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

          Kommentar


          • #35
            Über der geposteten Funktion.
            Ja, steht auf E_ALL, keine Fehlermeldung!

            Kommentar


            • #36
              imho ist aber $tmp dein ORIGINALES Array und nur dieses hat einen Subarray mit Key 'name' drin. Dein $sortTmp hat nur noch nummerische Indices und da brauchst du weder multisort noch usort. Da jedes Array Element in $sortTmp nur einen Wert hat kannst du auch gleich die "normalen" Sortierfkt verwenden.

              Gruss

              tobi
              Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

              [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
              Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

              Kommentar


              • #37
                Original geschrieben von jahlives
                imho ist aber $tmp dein ORIGINALES Array und nur dieses hat einen Subarray mit Key 'name' drin. Dein $sortTmp hat nur noch nummerische Indices und da brauchst du weder multisort noch usort. Da jedes Array Element in $sortTmp nur einen Wert hat kannst du auch gleich die "normalen" Sortierfkt verwenden.

                Gruss

                tobi
                OK,

                ich habe nun asort() auf das $sortTmp angewendet, und dann erscheinen die Ordner oben zuerst und dann die Dateien. Aber die Dateien sollen doch zwischen den Ordnern sein :S

                Gruss
                Henning

                Kommentar


                • #38
                  Code:
                  array(5) {
                  [0]=>  string(9) "Dokumente" 
                  [1]=>  string(13) "nokia_n95.jpg" 
                  [2]=>  string(19) "nokia_n95_bild2.jpg"
                  [3]=>  string(24) "Vertragsbestaetigung.pdf" 
                  [4]=>  string(8) "Verträge" 
                  }
                  Das muss aber mit sort() gehen. asort() sortiert absteigend ! Hast du denn das Ergebnis der Sortierung mit var_dump() ausgeben lassen oder hast du es mittels einer for-Schleife ausgelesen ?
                  Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

                  [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
                  Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

                  Kommentar


                  • #39
                    Hallo jahlives,

                    ich habe es sowohl per var_dump() als auch durch eine Schleife ausgegeben. Beide haben das gleiche, negative Ergebnis. Auch bei sort()....

                    oO

                    Viele Grüße
                    Henning

                    Kommentar


                    • #40
                      Mal versucht ?
                      PHP-Code:
                      return $sortTmp
                      Weil $tmp ist dein Originalarray welches du eben nicht sortierst.

                      Gruss

                      tobi
                      Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

                      [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
                      Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

                      Kommentar


                      • #41
                        Ich habe das var_dump() direkt in der Funktion vor und nach dem Sort eingefügt. Daher ist das return erstmal uninteressant...

                        Kommentar


                        • #42
                          Kannst du bitte nochmal genauer dein Problem beschreiben, "Ebenfalls nciht" ist keine Fehlerbeschreibung. Du hast verschiedenen Vorschläge bekommen die dir helfen das Problem zu lösen. Wenn du nur rum rätst kann dir keine helfen.
                          Die Regeln | rtfm | register_globals | strings | SQL-Injections | [COLOR=silver][[/COLOR][COLOR=royalblue]–[/COLOR][COLOR=silver]][/COLOR]

                          Kommentar


                          • #43
                            Ich habe das var_dump() direkt in der Funktion vor und nach dem Sort eingefügt
                            Das glaube ich dir schon NUR hast du auch den richtigen, sprich sortierten Array ausgegeben, oder wie im return nur deinen unsortierten Array $temp ?

                            Gruss

                            tobi
                            Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

                            [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
                            Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

                            Kommentar


                            • #44
                              Original geschrieben von jahlives
                              Das glaube ich dir schon NUR hast du auch den richtigen, sprich sortierten Array ausgegeben, oder wie im return nur deinen unsortierten Array $temp ?

                              Gruss

                              tobi
                              Sowohl, als auch!

                              Kommentar


                              • #45
                                (SELECT f.documentFileName AS name FROM documentFile AS f WHERE f.documentFileFolder = 1)
                                UNION
                                (SELECT d.documentFolderName AS name FROM documentFolder AS d WHERE d.documentFolderParent = 1)
                                ORDER BY name

                                Kommentar

                                Lädt...
                                X