Skip to content

Instantly share code, notes, and snippets.

@spolischook
Last active January 27, 2016 01:18
Show Gist options
  • Save spolischook/f858d92cbe65212af0fc to your computer and use it in GitHub Desktop.
Save spolischook/f858d92cbe65212af0fc to your computer and use it in GitHub Desktop.
Get all files recursively
<?php
/**
* @param $dir
* @param array $files
* @return array
*/
protected function getFiles($dir, array &$files = [])
{
foreach (scandir($dir) as $file) {
if (in_array($file, [".", ".."])) {
continue;
}
$fullPath = $dir.'/'.$file;
if (is_dir($fullPath)) {
$this->getFiles($fullPath, $files);
} else {
$files[] = $fullPath;
}
}
return $files;
}
@dxops
Copy link

dxops commented Jan 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment