Is there a way that I can have PHP get a file by a Regexp search? I know how to open and read a directory no problem, but finding a particular file is the problem.
Here is an example, I have a logo which may end in any of the following extensions: .bmp, .png, .jpg, .jpeg, or .gif. However, the name of the file will always be icon.someext.
$filesDirectory = scandir("/files");
foreach($filesDirectory as $file) {
[Regexp find logo here] ? $logo = $file : null;
}
echo $logo; // Returns something like logo.png
Thank you for your time.
You can use
globwith wildcard andGLOB_BRACE: