tags:

views:

29

answers:

1

Is it possible/how can I open a text file in PHP using a file mask?

The files are going to be named for example:

abcdef_072810_999222.txt abcdef_072910_123456.txt abcdef_073010_888884.txt

So I want to fopen or rename the file like this (notice the * mask) :

"abcdef_".date("mdy")."_*.txt"

I would like to avoid a read directory contents, loop through ... if possible.

+3  A: 

You can use the glob function.

foreach (glob("*.txt") as $filename) {
    echo "$filename size " . filesize($filename) . "\n";
}
Sarfraz