I am currently working on a PHP project where I need to use the glob function. I've been reading the PHP documentation about it, but there's one thing I can't figure out. Is it possible to use a variable instead of a string as the pattern parameter in the glob function?
Here's what I'm trying to do. I have a variable called $fileExtension which holds the file extension I'm interested in. Let's say it's "pdf". I want to use this variable as the pattern parameter in the glob function, like this: glob("path/to/files/*.$fileExtension").
But when I try this, it doesn't seem to work. I only get an empty array as a result. I've also tried using concatenation, like glob("path/to/files/*." . $fileExtension), but that didn't work either.
Am I doing something wrong? Is it not possible to use a variable inside the glob function? If not, is there any workaround or alternative approach I can use to achieve the same result?
I appreciate any help or insights on this matter.