In data2
directory, ho questi file:Perché la funzione PHP glob() restituisce file che non corrispondono al carattere jolly?
Con questo codice (in esecuzione su Mac), voglio ottenere solo i file che terminano con .xls
:
$file_names = glob('data2/*.xls');
foreach ($file_names as $file_name) {
echo $file_name . '<br/>';
}
I ci si aspetterebbe che questo codice restituisse un file 27template.xls
, tuttavia restituisce anche i file con TEMP
e aggiunge un .xls
a questi:
Aggiunto: anche se cambio smaller.xls
a smaller.xlsx
allora non lo trova come previsto, ma se cambio a smaller.NNN
che trova smaller.NNN.xls
.
Come utilizzare glob()
per ottenere solo i file .xls
?
Che cosa? –
Impossibile riprodurre su Mac OS X 10.6.5 con PHP 5.3.0. Restituisce solo '27template.xls' come previsto per me. – BoltClock
Sei sicuro che i file non abbiano questa estensione, nascosta nell'interfaccia utente? – regilero