Click to See Complete Forum and Search --> : foo.txt vs *.txt


Daria
10-12-2005, 09:29 AM
Is it possible to manipulate *.txt file instead of foo.txt?
I will have to work with different file every day (one file with the different name, in the same directory FTP'd daily).

1) Is there a way not to specify the filename, but simply work with whatever that file is in the folder?

2) Can it also be done to every file in the specified folder, regardless of their names, if there is more then one file? (they all are *.txt format)

NogDog
10-12-2005, 09:52 AM
You could perhaps do something like this:

<?php
$dir = 'text_files';
if ($handle = opendir('$dir')) {
while (false !== ($file = readdir($handle))) {
if (preg_match('/.*\.txt$/i', $file) {
# do whatever needs to be done with "$dir/$file";
}
}
closedir($handle);
}
?>

Daria
10-12-2005, 03:31 PM
Thanks, Man!