PHP - Find File in Directory By File Name

1.5k views Asked by At

I have a directory full of filenames that contain unix timestamps.

file_1434320602.data
file_1434320352.data
file_1434320112.data
file_1434320032.data

How would I get about loading them up in PHP so that I can select the one which I needed?

1

There are 1 answers

0
dynamic On BEST ANSWER

There are many ways you can do it. The simplest in this case is glob:

$files = glob('/path/to/file_*.data');
print_r($files);