php遍历文件夹(或文件)
<?php function read_dir($dir){ $arr = array(); $arr[] = $dir; if (is_dir($dir)){ $dh = opendir($dir); if (!$dh){ return $arr; } while ($file = readdir($dh)){ if ($file == '.' || $file == '..'){ continue; } $file = $dir . '/' . $file; $tmp = read_dir($file); $arr = array_merge($arr,$tmp); } } return $arr; } ?>