-----Original Message-----
From: Aviv Revach [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 12, 2001 10:01 PM
To: [EMAIL PROTECTED]
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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to