<?php
$fileext=extension("file.exe" // $fileext равно exe
$fileext=extension("FILE.sub.ExE" // $fileext равно exe
?>
<?php
function pathinfo_utf($path, $options="") {
if(strpos($path, '/') !== false){
$basename = end(explode('/', $path));
}elseif(strpos($path, '\') !== false){
$basename = end(explode('\', $path));
}else{
return(false);
}
if(empty($basename)) {
return(false);
}
$dirname = substr($path, 0, strlen($path) - strlen($basename) - 1);
if (strpos($basename, '.') !== false)
{
$extension = end(explode('.', $path));
$filename = substr($basename, 0, strlen($basename) - strlen($extension) - 1);
}
else
{
$extension = '';
$filename = $basename;
}
switch($options){
case PATHINFO_DIRNAME:
return($dirname);
break;
case PATHINFO_BASENAME:
return($basename);
break;
case PATHINFO_EXTENSION:
return($extension);
break;
case PATHINFO_FILENAME:
return($filename);
break;
default:
return(
array(
'dirname' => $dirname,
'basename' => $basename,
'extension' => $extension,
'filename' => $filename
));
break;
}
}
function extension($file){
if(function_exists('pathinfo_utf')){
$ext = pathinfo_utf($file, PATHINFO_EXTENSION);
}else{
$ext = pathinfo($file, PATHINFO_EXTENSION);
}
$ext = strtolower($ext);
return($ext);
}
?>
?>