Last active
November 16, 2016 03:07
-
-
Save tohokuaiki/e748082b880ed72907b67cce28c89210 to your computer and use it in GitHub Desktop.
ディレクトリ以下の全てのファイルを列挙
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getFileList($dir, $list=array('dir'=> array(), 'file' => array())) | |
{ | |
if (is_dir($dir) == false) { | |
return $list; | |
} | |
$dh = opendir($dir); | |
if ($dh) { | |
while (($file = readdir($dh)) !== false) { | |
if ($file == '.' || $file == '..'){ | |
continue; | |
} | |
else if (is_dir("$dir/$file")) { | |
$list = getFileList("$dir/$file", $list); | |
$list['dir'][] = "$dir/$file"; | |
} | |
else { | |
$list['file'][] = "$dir/$file"; | |
} | |
} | |
} | |
closedir($dh); | |
return $list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PHPでディレクトリ以下のファイル一覧を取得