Last active
January 27, 2016 01:18
-
-
Save spolischook/f858d92cbe65212af0fc to your computer and use it in GitHub Desktop.
Get all files recursively
This file contains hidden or 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 | |
/** | |
* @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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OOP way is http://php.net/manual/ru/class.recursivedirectoryiterator.php