Last active
July 12, 2016 12:01
-
-
Save rkalkani/c565e368a88c85777ce2293438c48558 to your computer and use it in GitHub Desktop.
PHP script to print all file in directory and sub-directories recursively
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 | |
// Origianlly : http://php.net/manual/en/function.scandir.php#110570 | |
function printAllFile($dir) { | |
$result = array(); | |
$cdir = scandir($dir); | |
foreach ($cdir as $key => $value) | |
{ | |
if (!in_array($value,array(".",".."))) | |
{ | |
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) | |
{ | |
$result[$value] = printAllFile($dir . DIRECTORY_SEPARATOR . $value); | |
} | |
else | |
{ | |
print($dir . DIRECTORY_SEPARATOR . $value); | |
echo PHP_EOL; | |
} | |
} | |
} | |
return ($result); | |
} | |
printAllFile('.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment