為了要判斷檔名和副檔名使用
$file="測試檔案.txt"
echo file_extension($file); // txt
echo file_extension($file,'N'); // 測試檔案
function file_extension($filename,$last='Y') {
$value = explode(".", $filename);
$extension = strtolower(array_pop($value));
$fileName = array_shift($value);
if ($last == 'N'){
return $fileName;
}else{
return $extension;
}
}