It's sometimes usefull to pick the name of the file without its extension, and this is very easy with php !
PHP Code:
<?php
$arr = explode(".", $allname);
$filename = $arr[0];
?>
$arr = explode(".", $allname);
$filename = $arr[0];
?>
PHP Code:
<?php
$filename = preg_replace( '/\.[a-z0-9]+$/i' , '' , 'dotted.file.Name' );
?>
$filename = preg_replace( '/\.[a-z0-9]+$/i' , '' , 'dotted.file.Name' );
?>
<?php
$FileNameTokens = explode('.', $allname);
$fileName = implode(".", array_slice($FileNameTokens, 0, count($FileNameTokens) - 1));
?>
$FileNameTokens = explode('.', $allname);
$fileName = implode(".", array_slice($FileNameTokens, 0, count($FileNameTokens) - 1));
?>
If this is a few hard to understand, this script is easier:
PHP Code:
<?php
function getFilenameWithoutExt($filename){
$pos = strripos($filename, '.');
if($pos === false){
return $filename;
}else{
return substr($filename, 0, $pos);
}
}
?>
function getFilenameWithoutExt($filename){
$pos = strripos($filename, '.');
if($pos === false){
return $filename;
}else{
return substr($filename, 0, $pos);
}
}
?>
I hope this will help you.