Answers for "how to seperate file extension from file name in php"

PHP
1

php regex remove file extension

$withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename);

This matches a dot followed by three or four characters which are not a dot or a space.
Posted by: Guest on June-19-2020
0

php regex file extension

$fileName = 'banner.jpg';

$ext = end(explode('.', $fileName));
$ext = substr(strrchr($fileName, '.'), 1);
$ext = substr($fileName, strrpos($fileName, '.') + 1);
$ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $fileName);
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
Posted by: Guest on June-20-2020

Code answers related to "how to seperate file extension from file name in php"

Browse Popular Code Answers by Language