Created
September 15, 2016 14:28
-
-
Save jonathan-dejong/0a6a5bb110050268785dc5e3fa63be14 to your computer and use it in GitHub Desktop.
Read all files of specific file type
This file contains 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 | |
/** | |
* Reads all files of a specific file type in a folder and returns them as an array. | |
* | |
*/ | |
public function read_files() { | |
$uploads_directory = trailingslashit( plugin_dir_path( dirname( __FILE__ ) ) ) . 'uploads/'; | |
$files = array_values( array_filter( scandir( $dir ), function( $file ) { | |
return ( pathinfo( $file, PATHINFO_EXTENSION ) != 'txt' ? false : true ); | |
} ) ); | |
return $files; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment