hi,
i was hoping someone could help me out,
basically i am writing numerous files into a directory,these files are named and grouped similarly to this:
ref4949494_5.html
ref4949494_9.html
ref4949494_3.html
ref676766_5.html
ref676766_27.html
ref676766_3.html
basically the only static part of the filename is the reference number and the extension....the underscore number is completely random. Therefore i cannot easily tell how many files grouped by reference number there are, and what there exact filename is.
At the moment I cannot reference these entries in a corresponding database table, which would make it easy to reference by number etc.
So I am trying to find a way to do a filename search, from looking at my problem I am thinking some of my solution would use php substr, as well as regular expressions....
I would be extremely grateful if anybody could post a tip or a link to a tip, I have tried a google search but nothing helpful has come up.
search for a file containing...xxx
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: search for a file containing...xxx
Take a look at glob()
Code: Select all
$matches = glob('/path/to/files/ref*.html');
echo '<pre>';
print_r($matches);
echo '</pre>';Re: search for a file containing...xxx
thank you,
i managed to find a working solution, by reading the directory and using a substr search, but i will look at glob because your solution looks incredibly short.
i managed to find a working solution, by reading the directory and using a substr search, but i will look at glob because your solution looks incredibly short.