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?

有帮助吗?

解决方案

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;
}

其他提示

You will want to look at glob.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top