zoukankan      html  css  js  c++  java
  • PHP读取文件夹所有文件并输出

    //获取文件目录列表,该方法返回数组
    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."//"; 
    }
    
  • 相关阅读:
    Logistic回归
    朴素贝叶斯
    决策树
    K-邻近(KNN)算法
    快速排序
    归并排序
    希尔排序
    插入排序
    选择排序
    浅谈系统服务分发
  • 原文地址:https://www.cnblogs.com/keringing/p/3577264.html
Copyright © 2011-2022 走看看