Created
October 26, 2012 20:26
-
-
Save adampatterson/3961278 to your computer and use it in GitHub Desktop.
recursive_glob
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
/** | |
* Function: recursive_glob | |
* Recursively goes through a folder and returns all files. | |
* | |
* Parameters: | |
* $pattern - String | |
* $flags - Boolean | |
* $path - String | |
* | |
* Returns: | |
* $files - Array | |
*/ | |
function recursive_glob($pattern='*', $flags = 0, $path='') | |
{ | |
$paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); | |
$files = glob($path.$pattern, $flags); | |
foreach ($paths as $path) { | |
$files=array_merge($files,recursive_glob($pattern, $flags, $path)); | |
} | |
return $files; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment