欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP使用遞歸方式列出當(dāng)前目錄下所有文件的方法

 更新時(shí)間:2015年06月02日 10:35:02   作者:無影  
這篇文章主要介紹了PHP使用遞歸方式列出當(dāng)前目錄下所有文件的方法,涉及php遞歸操作文件的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了PHP使用遞歸方式列出當(dāng)前目錄下所有文件的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

<?php
function filelist($pathname,$i){
//定義一個(gè)filelist函數(shù)
    $dir=opendir($pathname);
    while(($file=readdir($dir))!== false){
        $fname=$pathname."/".$file;
        if(is_dir($fname)&&$file!="."&&$file!=".."){
            for($tmp=0;$tmp<=8*$i;$tmp++)
                echo "&nbsp;";
            echo '<input type="checkbox" name="Bike">';
            echo "is directory:".$fname."<br>";
            filelist($fname,$i+1);
        }elseif($file!="."&&$file!=".."){
            for($tmp=0;$tmp<=8*$i;$tmp++)
                echo "&nbsp;";
            echo '<input type="checkbox" name="Bike">';
            echo $fname."<br>";
        }
    }
    chdir("..");
    closedir($dir);
}
filelist("/home/zhou/shell",0);
//列出/home/zhou/shell下的所有文件及目錄。
?>

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論