Tengo la misma necesidad, y trató de utilizar pegote pero esta función no parece ser portátil:
Véanse las notas de http://php.net/manual/en/function.glob.php:
Nota: Esta función no está disponible en algunos sistemas (por ejemplo, el antiguo SO Sun).
Nota: El indicador GLOB_BRACE no está disponible en algunos sistemas que no son GNU, como Solaris.
También más lento que opendir, echar un vistazo a: Which is faster: glob() or opendir()
así que he hecho una función fragmento que hace la misma cosa:
function resolve($name) {
// reads informations over the path
$info = pathinfo($name);
if (!empty($info['extension'])) {
// if the file already contains an extension returns it
return $name;
}
$filename = $info['filename'];
$len = strlen($filename);
// open the folder
$dh = opendir($info['dirname']);
if (!$dh) {
return false;
}
// scan each file in the folder
while (($file = readdir($dh)) !== false) {
if (strncmp($file, $filename, $len) === 0) {
if (strlen($name) > $len) {
// if name contains a directory part
$name = substr($name, 0, strlen($name) - $len) . $file;
} else {
// if the name is at the path root
$name = $file;
}
closedir($dh);
return $name;
}
}
// file not found
closedir($dh);
return false;
}
Uso:
$file = resolve('/var/www/my-website/index');
echo $file; // will output /var/www/my-website/index.html (for example)
Espero que pueda ayudar a alguien, Ioan
'glob' también se puede utilizar con una expansión de llaves tipo bash:' glob ("./ uploads/filename. {Jpg, jpeg, png, gif}", GLOB_BRACE) '. – Gumbo
@pekka: Muchas gracias. –