/*** getdir()去文件夹列表* getfile()去对应文件夹下面的文件列表* 二者的区别在于判断有没有“.”后缀的文件,其他都一样* edit bbs.it-home.org*///获取文件目录列表,该方法返回数组function getDir($dir) {$dirArray[]=NULL;if (false != ($handle = opendir ( $dir ))) {$i=0;while ( false !== ($file = readdir ( $handle )) ) {//去掉"“.”、“..”以及带“.xxx”后缀的文件if ($file != "." && $file != ".."&&!strpos($file,".")) {$dirArray[$i]=$file;$i++;}}//关闭句柄closedir ( $handle );}return $dirArray;}//获取文件列表function getFile($dir) {$fileArray[]=NULL;if (false != ($handle = opendir ( $dir ))) {$i=0;while ( false !== ($file = readdir ( $handle )) ) {//去掉"“.”、“..”以及带“.xxx”后缀的文件if ($file != "." && $file != ".."&&strpos($file,".")) {$fileArray[$i]="./imageroot/current/".$file;if($i==100){break;}$i++;}}//关闭句柄closedir ( $handle );}return $fileArray;}//调用方法getDir("./dir")……可以是绝对路径也可以是相对路径?>复制代码
