Re: Read Files
| From: | Chris Wesley | Date: | Sat, 30 Nov 2002 20:25:29 +0000 |
| Subject: | Re: Read Files | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-126573@lists.php.net to get a copy of this message | ||
On Sat, 30 Nov 2002, Randum Ian wrote:
> I have a directory of files which are split up into sections based on
> 'full', 'summary' and 'competitions'. This is shown in the
> filename as
> follows:
>
> ministry-full-6122002.inc
>
> I want to be able to search thru the dir looking for all the 'full'
> files, then sorting them by date and including them in my html page in
> date order.
To get an array full of the file names you want:
$interestingFiles = array();
$dir = opendir( "/path/to/directory" ) or die( "Could not open dir" );
while( $dirEntry = readdir( $dir ) ){
if( ereg( "full", $dirEntry) ){
array_push( $interestingFiles, $dirEntry );
}
}
I'll leave it up to you to sort $interestingFiles by the date in the
element values, since I don't recognize a date in your file-naming
convention.
g.luck,
~Chris