I'd like to be able to select a file by just giving it's name (without extension). For example, I might have a variable $id
holding 12
. I want to be able to select a file called the-id-in-the-variable, say, 12.png
from a directory, but it may have any one of a number of file extensions, listed below:
- .swf
- .png
- .gif
- .jpg
There is only one occurrence of each ID. I could use a loop and file_exists()
, but is there a better way?
Thanks,
James