Đây là phương án liệt kê danh sách các tập tin hình ảnh (gif, jpg, png) trong thư mục /image: PHP: <?phpdefine('PATH', 'image/');$files = array();$dir = opendir(PATH);while ($f = readdir($dir)) {if (eregi("\.gif|\.png|\.jpg", $f))array_push($files, $f); }closedir($dir);$data = array();if (! empty($files)) {foreach ($files as $k => $v) {echo '<img src="' . $v . '" width="300" />'; }?}