只需要掌握两个方法:opendir 【打开目录】 readdir【读取目录下的文件】
$path1 = 'dir';
$handle = opendir($path1);
while (false !== ($file = readdir($handle))) {
$tmp =explode(".",$file);
if($tmp[1] == 'jpg'){
echo "<img src='".$path1.'/'.iconv('GBK','UTF-8',$file)."'/>";
echo "<center style='font-size:16px;font-weight:bold;padding:20px 0;background:white;margin-top:-10px;'>".iconv('GBK','UTF-8',$file)."</center>";
}
}