문제

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