note 95863 added to function.scandir
| From: | hinghoo at osu1 dot php dot net | Date: | Tue, 26 Jan 2010 18:17:13 +0000 |
| Subject: | note 95863 added to function.scandir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165325@lists.php.net to get a copy of this message | ||
/**
* 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'));
----
Server IP: 208.69.120.55
Probable Submitter: 67.164.94.173
----
Manual Page -- http://www.php.net/manual/en/function.scandir.php
Edit -- https://master.php.net/note/edit/95863
Del: integrated -- https://master.php.net/note/delete/95863/integrated
Del: useless -- https://master.php.net/note/delete/95863/useless
Del: bad code -- https://master.php.net/note/delete/95863/bad+code
Del: spam -- https://master.php.net/note/delete/95863/spam
Del: non-english -- https://master.php.net/note/delete/95863/non-english
Del: in docs -- https://master.php.net/note/delete/95863/in+docs
Del: other reasons-- https://master.php.net/note/delete/95863
Reject -- https://master.php.net/note/reject/95863
Search -- https://master.php.net/manage/user-notes.php