foreach (glob("*.gif"), glob("*.jpg"), glob("*.png") as $image);

Discussion in 'PHP' started by jpinheiro, Aug 9, 2008.

  1. #1
    Cant Get it to display the images in the directory unless i only do 1 file type :p

    Please fix ive already tried

    
    
    <?php
    foreach (glob("*.gif"), glob("*.jpg"), glob("*.png") as $image); 
      echo '<img src=\"http://mytestsite.net76.net/imagehost/uploaded/$image\" /></td>';
    }
    ?>
    
    
    PHP:

     
    jpinheiro, Aug 9, 2008 IP
  2. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #2
    anybody able to fix whatever my mistake is?
     
    jpinheiro, Aug 9, 2008 IP
  3. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #3
    come on people some1 must know how to fix this :| ....
     
    jpinheiro, Aug 9, 2008 IP
  4. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #4
    $file_type = array('gif','jpg','png');
    
    foreach($file_type as $ext){
    
       foreach(glob('*.'.$ext) as $image){
       
           echo '<img src=\"http://mytestsite.net76.net/imagehost/uploaded/'.$image.'\" /></td>';
       
       }//end for
    
    }//end for
    PHP:
     
    php-lover, Aug 10, 2008 IP
  5. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #5
    EricBruggema, Aug 10, 2008 IP
  6. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #6
    yea it can i fixed it myself finally the code he gave me just gives me errors :\ so i rebuilt my code so it works now thanks though :D
     
    jpinheiro, Aug 10, 2008 IP