Skip to content

Instantly share code, notes, and snippets.

@entimm
Created March 9, 2019 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save entimm/abe49b7463b32b6b952af9e95e0dd76c to your computer and use it in GitHub Desktop.
Save entimm/abe49b7463b32b6b952af9e95e0dd76c to your computer and use it in GitHub Desktop.
getDirContents
<?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