Created
December 8, 2010 02:28
-
-
Save riaf/732793 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 | |
/** | |
* 再帰的に scandir する | |
* | |
* @author Keisuke SATO <[email protected]> | |
**/ | |
function recursive_scandir($path, $result=array()) { | |
if (is_dir($path)) { | |
$path = rtrim($path, '/'). '/'; | |
$dirs = array_diff(scandir($path), array('.', '..')); | |
foreach ($dirs as $dir) { | |
if (is_dir($path. $dir)) { | |
$result[] = $path. $dir. '/'; | |
$result = recursive_scandir($path. $dir. '/', $result); | |
} else if (is_file($path. $dir)) { | |
$result[] = $path. $dir; | |
} | |
} | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment