[TYPO3-dev] t3lib_div::getFilesInDir

Stephen Bungert stephenbungert at yahoo.de
Mon Jun 28 16:26:10 CEST 2010


I thought I might have to do this,

I mean by "first file" what ever is first in the array that would have 
normally be returned by the function, but insetad of trying to get the other 
file names, it just returns with an array of one file name.


"Marc Wöhlken" <woehlken at quadracom.de> schrieb im Newsbeitrag 
news:mailman.1.1277482529.32758.typo3-dev at lists.typo3.org...
> 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