Home  >  Article  >  Backend Development  >  PHP目录中列出所有文件和文件夹函数

PHP目录中列出所有文件和文件夹函数

WBOY
WBOYOriginal
2016-06-20 13:02:181262browse

function list_files($dir)<br />{<br />    if(is_dir($dir))<br />    {<br />        if($handle = opendir($dir))<br />        {<br />            while(($file = readdir($handle)) !== false)<br />            {<br />                if($file != "." && $file != ".." && $file != "Thumbs.db"/*pesky windows, images..*/)<br />                {<br />                    echo '<a target="_blank" href="'.$dir.$file.'">'.$file.'</a><br>'."\n";<br />                }<br />            }<br />            closedir($handle);<br />        }<br />    }<br />}


Statement:
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