获取不带后缀名的文件名的两种方法
来源:互联网 发布:山西省大数据产业协会 编辑:程序博客网 时间:2024/05/20 06:08
第一种方法用截取字符串实现,第二种方法用正则去实现!
<?php/**@Description:取得不带后缀名的文件名***/function getFileNameOne($path=''){if(empty($path)){die('nothing');}if(strrpos($path, '/')){$path = basename($path);}$posOne = strpos($path, '.php');$filename = substr($path, 0, $posOne);echo $filename.'<br/>';}function getFileNameTwo($path=''){if(empty($path)){die('nothing');}if(strrpos($path, '/')){$path = basename($path);}preg_match('/[\w]*+\.[\w]*+/', $path, $filename);print_r('<br/>'.$filename[0]);}function microtime_float(){list($usec, $sec) = explode(" ", microtime());return ((float)$usec + (float)$sec);}date_default_timezone_set('PRC');$time_start = microtime_float();for($i = 0; $i <= 10000; $i++){$newPath = 'C:/AppServ/www/testOne.class.php';//getFilenameOne($newPath);getFileNameTwo($newPath);}$time_end = microtime_float();$time = $time_end - $time_start;echo $time;?>效果:
0 0
- 获取不带后缀名的文件名的两种方法
- Delphi获取文件名、文件名不带扩展名、文件名的方法;delphi 获取文件所在路径
- C/C++ 获取不带路径的文件名的方法
- php获取不带后缀的文件名
- android--由文件名获取文件Id的两种方法
- js 文件名截取(后缀名、全名、不带后缀名)
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名。
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- 获取带路径的文件的文件名方法
- 获取input-file的文件名、后缀名(兼容IE)
- C# 获取某一文件夹下给定后缀名的文件名列表
- shell 获取一个文件的文件名和后缀名
- 获取全路径文件名的文件名/文件位置/文件的后缀名/文件的前缀
- PHP获取文件后缀名的几种方法
- php获取文件后缀名的几种方法
- python3.3 django错误处理“sre_constants.error: nothing to repeat”
- ios动画系列 -- UIView的transform
- Attempt to refer to a unregistered pool by its alias 'xxx'
- 2014腾讯测试实习面试题
- JSP 简单表单显示例子
- 获取不带后缀名的文件名的两种方法
- 是哪些技术把你和小伙伴分开了?
- JLink + Vmware调试linux内核
- Jlink + Vmware虚拟机调试uboot
- 字符串倒序(the c programming)
- cocos2d-x 播放视频 on Android
- 2014哈工程校赛
- hdu 1045 贪心回溯
- Java 上传文件 Socket类应用 多线程上传 有注释哈,上传完请看看文件大小是否正常