Arrays zusammenführen

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

  • Arrays zusammenführen

    Habe ein Problem ich möchte aus :
    Array
    (
    [0] => File1
    [1] => Array
    (
    [0] => File2
    [1] => File3
    )

    )


    ein Array machen

    Array
    (
    [0] => File1
    [1] => File2
    [2] => File3
    )

    fällt euch da spontan was ein womit ich das machen kann ?

  • #2
    array_merge?

    peter
    Nukular, das Wort ist N-u-k-u-l-a-r (Homer Simpson)
    Meine Seite

    Comment


    • #3
      Ne Schleife über den äusseren Array. Dann falls wieder ein Array, mittels weiterer Schleife die Elemente auslesen und anfügen. Falls es direkt ein Element ist kannst du es auch direkt an den Array anfügen
      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)

      Comment


      • #4
        genau jahlives

        das ist ja die Frage wie

        Comment


        • #5
          PHP Code:
          $ar array_merge($ar$ar[1]);
          unset(
          $ar[1]);
          sort($ar); 
          Gruss
          H2O

          Comment


          • #6
            ja ich glaube das funktioniert so muss nur noch an meine Funktionen anpassen vielen dank wiedermal an euch

            Comment


            • #7
              das ist ja die Frage wie
              z.B. so
              PHP Code:
              $ret = array();
              foreach(
              $array as $wert){
                if(
              is_array($wert)){
                  foreach(
              $wert as $w){
                    
              $ret[] = $w;
                  }
                }else{
                  
              $ret[] = $wert;
                }

              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)

              Comment

              Working...
              X