Skip to content

Instantly share code, notes, and snippets.

@ssut
Created September 10, 2013 12:37
Show Gist options
  • Save ssut/6508831 to your computer and use it in GitHub Desktop.
Save ssut/6508831 to your computer and use it in GitHub Desktop.
PHP Folder scan function.
<?php
function find_entry($dir, $orign_dir='') {
if(!is_dir($dir)) return null;
$d = dir($dir);
$result = "";
while($entry = $d->read()) {
if($entry != "." && $entry != "..") {
if(is_dir($dir . "/" . $entry)) {
$result .= find_entry($dir . "/" . $entry, $orign_dir ? $orign_dir : $dir);
} else {
$result .= "{$dir}/{$entry}\n";
}
}
}
$d->close();
return str_replace($orign_dir ? $orign_dir : $dir, '', $result);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment