//获取文件目录列表,该方法返回数组
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]=$file;
//echo($file);
if($i==100){
break;
}
$i++;
}
}
//关闭句柄
closedir ( $handle );
}
return $fileArray;
}
输出
$font_list=getFile("../fonts/fontfile/");//获取数组值
foreach($font_list as $software) //遍历数组并输出
{
echo $software."//";
}