PHP uses recursive method to list all files in the current directory, _PHP tutorial

WBOY
Release: 2016-07-13 09:51:57
Original
782 people have browsed it

PHP uses a recursive method to list all files in the current directory.

The example in this article describes how PHP uses a recursive method to list all files in the current directory. Share it with everyone for your reference. The specific implementation method is as follows:

<&#63;php<br />function filelist($pathname,$i){<br />//定义一个filelist函数<br />    $dir=opendir($pathname);<br />    while(($file=readdir($dir))!== false){<br />        $fname=$pathname."/".$file;<br />        if(is_dir($fname)&&$file!="."&&$file!=".."){<br />            for($tmp=0;$tmp<=8*$i;$tmp++)<br />                echo " ";<br />            echo '<input type="checkbox" name="Bike">';<br />            echo "is directory:".$fname."<br>";<br />            filelist($fname,$i+1);<br />        }elseif($file!="."&&$file!=".."){<br />            for($tmp=0;$tmp<=8*$i;$tmp++)<br />                echo " ";<br />            echo '<input type="checkbox" name="Bike">';<br />            echo $fname."<br>";<br />        }<br />    }<br />    chdir("..");<br />    closedir($dir);<br />}<br />filelist("/home/zhou/shell",0);<br />//列出/home/zhou/shell下的所有文件及目录。<br />&#63;>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1011253.htmlTechArticlePHP uses recursive method to list all files in the current directory. This article describes the example of PHP using recursive method to list Method for all files in the current directory. Share it with everyone for your reference...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template