Question

friends. I need to locate a file, stored in my site while using php and finding it with a part of its name. I cant locate it by its entire name because the php file cannot know its extension. It might be png and might be jpg.

How do I do that?

Was it helpful?

Solution

You could use glob()

Here's an example:

<?php

foreach(glob("path/to/files/imagename.*") as $file)
{
    // do something with the file here
    echo $file;
}

OTHER TIPS

You will want to look at glob.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top