note 95863 deleted from function.scandir by danbrown
| From: | danbrown@php.net | Date: | Tue, 26 Jan 2010 18:22:24 +0000 |
| Subject: | note 95863 deleted from function.scandir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165326@lists.php.net to get a copy of this message | ||
Note Submitter: hinghoo
----
/**
* get an array of files matching a filespec
* @param string $dir
* @param string $ext
* @return array
*/
function scandir_filterby($dir, $ext){
$files = scandir($dir);
foreach($files as $file){
$extension = strtolower(substr(strrchr($file, '.'), 1));
if($extension == $ext ){
$matchingFiles[] = $file;
}
}
return $matchingFiles;
}
//example usage
print_r(scandir_filterby('.', 'csv'));