ho questo codice PHP:PHP, ottenere il nome del file senza estensione di file
function ShowFileExtension($filepath)
{
preg_match('/[^?]*/', $filepath, $matches);
$string = $matches[0];
$pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE);
if(count($pattern) > 1)
{
$filenamepart = $pattern[count($pattern)-1][0];
preg_match('/[^?]*/', $filenamepart, $matches);
return strtolower($matches[0]);
}
}
Se ho un file chiamato my.zip
, questa funzione restituisce .zip
.
voglio fare il contrario, voglio che la funzione restituisca my
senza l'estensione.
Il file è solo una stringa in una variabile.
arresto regexing. – Pacerier
Risposta migliore: ** http: //stackoverflow.com/questions/8123998/file-name-without-extension** –