J'ai ce code PHP :
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]);
}
}
Si j'ai un fichier nommé my.zip
cette fonction renvoie .zip
.
Je veux faire l'inverse, je veux que la fonction renvoie my
sans l'extension.
Le fichier est juste une chaîne de caractères dans une variable.
0 votes
Meilleure réponse : stackoverflow.com/questions/8123998/file-name-without-extension