Skip to content

Instantly share code, notes, and snippets.

@riaf
Created December 8, 2010 02:28
Show Gist options
  • Save riaf/732793 to your computer and use it in GitHub Desktop.
Save riaf/732793 to your computer and use it in GitHub Desktop.
<?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