Pregunta

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?

¿Fue útil?

Solución

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

Otros consejos

You will want to look at glob.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top