Last active
August 29, 2015 14:26
-
-
Save thorbrink/27aa6daa49deb7c609e2 to your computer and use it in GitHub Desktop.
Get all files in folder 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 | |
function get_recursive_files_array( $dir, $files = null ) { | |
$files_in_folder = scandir( $dir ); | |
$files = ( null === $files ) ? array() : $files; | |
foreach ( $files_in_folder as $file ) { | |
if ( ! is_dir( $dir . $file ) ) { | |
$files[] = $dir . $file; | |
} elseif ( '..' !== $file && '.' !== $file ) { | |
$files = get_recursive_files_array( $dir . $file . '/' ); | |
} | |
} | |
return $files; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment