public static function getFileList(string $path, array $exts = null) : array
    {
        $files = [];
        if (is_dir($path) && ($dh = opendir($path))) {
            while (($file = readdir($dh)) !== false) {
                if ($file === '.' || $file === '..' || $file === '.DS_Store') {
                    continue;
                } elseif (is_dir("{$path}/{$file}")) {
                    $files = array_merge($files, self::getFileList("{$path}/{$file}", $exts));
                } elseif (is_null($exts)) {
                    $files[] = "{$path}/{$file}";
                } elseif (in_array(pathinfo("{$path}/{$file}", PATHINFO_EXTENSION), $exts)) {
                    $files[] = "{$path}/{$file}";
                } else {
                    continue;
                }
            }
            closedir($dh);
        }
        return $files;
    }
public static function getFileList(string $path, array $exts = null) : array
    {
        $files = [];
        if (is_dir($path) && ($dh = opendir($path))) {
            while (($file = readdir($dh)) !== false) {
                if ($file === '.' || $file === '..' || $file === '.DS_Store') {
                    continue;
                } elseif (is_dir("{$path}/{$file}")) {
                    $files = array_merge($files, self::getFileList("{$path}/{$file}", $exts));
                } elseif (is_null($exts)) {
                    $files[] = "{$path}/{$file}";
                } elseif (in_array(pathinfo("{$path}/{$file}", PATHINFO_EXTENSION), $exts)) {
                    $files[] = "{$path}/{$file}";
                } else {
                    continue;
                }
            }
            closedir($dh);
        }
        return $files;
    }
public static function getFileList ( string $ path , array $ exts = null ) : array { $ files = [ ] ; if ( is_dir ( $ path ) && ( $ dh = opendir ( $ path ) ) ) { while ( ( $ file = readdir ( $ dh ) ) !== false ) { if ( $ file === '.' || $ file === '..' || $ file === '.DS_Store' ) { continue ; } elseif ( is_dir ( "{$path}/{$file}" ) ) { $ files = array_merge ( $ files , self :: getFileList ( "{$path}/{$file}" , $ exts ) ) ; } elseif ( is_null ( $ exts ) ) { $ files [ ] = "{$path}/{$file}" ; } elseif ( in_array ( pathinfo ( "{$path}/{$file}" , PATHINFO_EXTENSION ) , $ exts ) ) { $ files [ ] = "{$path}/{$file}" ; } else { continue ; } } closedir ( $ dh ) ; } return $ files ; }
get file paths
@param  string $path
@param  array  $exts extensions
@return array
get file paths