Created
March 9, 2019 05:20
-
-
Save entimm/abe49b7463b32b6b952af9e95e0dd76c to your computer and use it in GitHub Desktop.
getDirContents
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 getDirContents($dir, &$results = array()){ | |
$files = scandir($dir); | |
foreach($files as $key => $value){ | |
$path = realpath($dir.DIRECTORY_SEPARATOR.$value); | |
if(!is_dir($path)) { | |
$results[] = $path; | |
} else if($value != "." && $value != "..") { | |
getDirContents($path, $results); | |
$results[] = $path . '/'; | |
} | |
} | |
return $results; | |
} | |
var_dump(getDirContents('/xampp/htdocs/WORK')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment