Created
September 10, 2013 12:37
-
-
Save ssut/6508831 to your computer and use it in GitHub Desktop.
PHP Folder scan function.
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 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