Array

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

  • Array

    Hallo

    Als PHP Anfänger stehe ich wieder mal vor einem Problem.
    Ich lasse mir Bilddateien aus einem Verzeichnis in ein Array ausgeben.
    Diese Bilddateien sind einmal als kleines Thumbnail und einmal als mittleres Thumbnail vorhanden.
    Nun möchte ich nur die kleinen Thumbnails zur weiterverarbeitung nutzen. Mein Array sieht momentan so aus:
    Code:
    Array
    (
        [0] => th_big_003.jpg
        [1] => thm_big_003.jpg
        [2] => th_big_004.jpg
        [3] => thm_big_004.jpg
        [4] => th_big_005.jpg
        [5] => thm_big_005.jpg
        [6] => th_big_006.jpg
        [7] => thm_big_006.jpg
        [8] => th_big_007.jpg
        [9] => thm_big_007.jpg
        [10] => th_big_008.jpg
        [11] => thm_big_008.jpg
        [12] => th_big_009.jpg
        [13] => thm_big_009.jpg
        [14] => th_big_011.jpg
        [15] => thm_big_011.jpg
        [16] => th_big_012.jpg
        [17] => thm_big_012.jpg
        [18] => th_big_002.jpg
        [19] => thm_big_002.jpg
        [20] => th_big_001.jpg
        [21] => thm_big_001.jpg
        [22] => th_big_010.jpg
        [23] => thm_big_010.jpg
    )
    Also ich brauche nur die Bilder mit th_big....jpg.
    Doch wie kann ich diese Filtern?

    Bedanke mich schon mal für die hilfe.

    Gruss Andreas

  • #2
    Re: Array

    strpos
    I don't believe in rebirth. Actually, I never did in my whole lives.

    Comment


    • #3
      Re: Array

      Original geschrieben von AndreasS
      Nun möchte ich nur die kleinen Thumbnails zur weiterverarbeitung nutzen.
      warum liest du dann eigentlich alle bilder aus?
      mit glob() bekommst du das sehr einfach hin.

      Comment


      • #4
        Oder auch so...
        PHP Code:
        foreach($array as $key=>$wert){
            if(
        $key%== 0){
                echo 
        $wert;
            }

        Setzt voraus, dass du das gewünschte Bild immer auf eine Index Position hast die mit modulo 2 0 ergibt.

        Gruss

        tobi
        Folgendes müsste eigentlich auch funzen
        PHP Code:
        $array glob('path/to/pics/th_big_*.jpg'); 
        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


        • #5
          Hallo

          Durch einen Computerabsturz hier meine späte Antwort.
          Möchte mich bei euch für die nützlichen Tips bedanken, vor allem den Tipp mit glob. Funktioniert!
          Nun habe ich aber noch eine Frage. Ich weiss, es gibt eine Möglichkeit, den Namen aus einem Array auszulesen und zu kürzen.
          Als Beispiel: /images/filialen/th_big_010.jpg
          Diesen möchte ich auf die letzten 7 Stellen kürzen. Doch wie heisst diese Funktion?


          Danke schonmal und Gruss
          Andreas

          Comment


          • #6
            substr

            Comment


            • #7
              Vielen Dank

              Comment

              Working...
              X