RE: [PHP] Seeking for files ending with '.txt' ..
| From: | Christian Joergensen | Date: | Tue, 13 Mar 2001 21:06:52 +0000 |
| Subject: | RE: [PHP] Seeking for files ending with '.txt' .. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-43712@lists.php.net to get a copy of this message | ||
-----Original Message-----
From: Aviv Revach [mailto:aviv_r@brillianet.com]
Sent: Monday, March 12, 2001 10:01 PM
To: php-general@lists.php.net
Subject: [PHP] Seeking for files ending with '.txt' ..
> I have a directory that contains many files. Some of these files have a
> '.txt' ending.
> I would like to know how could I locate each one of the '.txt' files.
This is easily done using PEAR:
<?php
require_once "File/Find.php";
$pattern = ".*\.txt$"; // Pattern...
$start_in = $DOCUMENT_ROOT; // Where to start...
$f=new File_Find();
$array=$f->search($pattern, $start_in);
(sizeof($array) == 0) ? print "Didn't find any files\n" : foreach($array as
$filename) print "$filename<br>\n";
?>
> For each file I find, I need to do a certain action, and should continue
> the search.
Here, i just print the filenames.
--
Christian Jorgensen
http://www.razor.dk