checking if a file exists on my file system

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

checking if a file exists on my file system

Post by jasongr »

Hello people

I need to find whether a file that begins with a certain prefix exists on my file system
The file starts with '1_'
It could be for example:
1_test.jpg
1_hello.jpg

basically it must start with '1_' but the rest cannot be assumed

Function file_exists takes a complete file name and returns true if it exists
it is only useful if I know the full file name (which I don't in my case)

is there a way to solve this (possible using regular expressions with file access)?

I'd rather not traverse the entire folder which contains 2000+ files

regards
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

glob() - Find pathnames matching a pattern
Post Reply