0

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?

Ben Rokah
  • 33
  • 3

2 Answers2

1

You will want to look at glob.

deceze
  • 510,633
  • 85
  • 743
  • 889
1

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;
}
Dale
  • 10,384
  • 21
  • 34