Description
Return the list of files in the directoryThis returns an array of all files, except directory pointers. Hopefully you don't have a recursive directory structure. If there are zillions of non-PHP files then subsequent processing might take a little longer than we'd like.
Usage
$array = oikb_list_files_in_directory( $directory );Parameters
- $directory
- ( string ) required – not expected to have trailing slash
Returns
array array of filesSource
File name: oik-batch/oik-list-previous-files.phpLines:
1 to 17 of 17
function oikb_list_files_in_directory( $directory ) { $iterableFiles = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $directory ) ); $files = array(); try { foreach ( $iterableFiles as $file ) { $fil = $file->getFilename(); if ( $fil !== "." && $fil !== ".." ) { $filename = $file->getPathname(); //echo $filename . PHP_EOL; $files[] = $filename; } } } catch ( \UnexpectedValueException $e ) { bw_trace2( 'Directory [%s] contained a directory we can not recurse into', $directory ); } return $files; }View on GitHub
