从文件的全名中获取不带扩展名的文件名
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从文件的全名中获取不带扩展名的文件名相关的知识,希望对你有一定的参考价值。
A flexible way to get the file name without the extension
/* Detailed notes are below the code. */ $str_full_filename = 'tricky_filename_.js.jpg.version2.jpg'; $str_extension = $arr[ $int_last_element ]; echo 'The extension is '.$str_extension; echo '<br /> The file name (without the extension) is: '.$filename_without_extension; /* This is a group of methods to get the extension of a file or get a filename without the extension; this is especially useful when you need to copy an image (say filename.jpg), resize and rename to something like the following: 1. filename_small.jpg 2. filename_medium.jpg 3. filename_large.jpg I'm not covering how to resize images, just a way to copy the name and the extension so you can keep names consistent. The way I did this is to anticipate strange file names, so files with an extension name in it more than once won't cause errors or inconsistency. */
以上是关于从文件的全名中获取不带扩展名的文件名的主要内容,如果未能解决你的问题,请参考以下文章