[TYPO3-dev] t3lib_div::getFilesInDir
Marc Wöhlken
woehlken at quadracom.de
Fri Jun 25 18:10:47 CEST 2010
Hi!
Am 25.06.2010 17:01, schrieb Stephen Bungert:
> Is there some function that allows you to do what t3lib_div::getFilesInDir
> does but set a limit to the number of files returned?
>
> I looked through the api but couldn't see anything, I want to get just the
> first file in the directory.
AFAIK there is no such method.
What exactly does "first file" mean? This would heavily depend on
whether you like it ordered by name, date or filesize. I believe you
should use t3lib_div::getFilesInDir() and extract the first filename
from the retunrned array on your own.
If you need this alot you may write a simple wrapper method:
function
getFirstFileInDir($path,$extensionList='',$prependPath=0,$order='',$excludePattern='')
{
$files =
t3lib_div::getFilesInDir($path,$extensionList,$prependPath,$order,$excludePattern);
if(count($files) > 0) {
return $files[0];
} else {
return $files;
}
}
Regards
Marc
--
...........................................................
Marc Wöhlken TYPO3 certified integrator
Quadracom - Proffe & Wöhlken
Rembertistraße 32 WWW: http://www.quadracom.de
D-28203 Bremen E-Mail: woehlken at quadracom.de
______________ PGP-Key: http://pgp.quadracom.de
More information about the TYPO3-dev
mailing list