2010-06-26 107 views
1

我需要使用glob獲取以「t_」開頭的所有圖像。我應該用什麼模式來做到這一點?迭代目錄中的特定文件

 //get any image files that begin with "t_" -- (t_image.jpg) not (image.jpg) 
     $images = glob("" . $dir . "*.jpg"); 

     foreach($images as $image) 
     { 
      echo $image; 
     } 

回答

4
foreach (glob("t_*.jpg") as $filename) { 
    echo "$filename size " . filesize($filename) . "\n"; 
} 

這意味着:

foreach (glob("$dir/t_*.jpg") as $filename) { 
    echo "$filename size " . filesize($filename) . "\n"; 
} 

參見:

http://ca2.php.net/manual/en/function.glob.php

相關問題