您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

怎么显示文件的扩展名 php中批量替换文件名的实现代码

2025/12/20 0:37:21发布22次查看
代码如下
复制代码 代码如下:
$dir = 'd:\program files\resource\application\skin\png\\';//注意这里的路径,最后要加两个\,第一个表示转意,但是这样容易遇到其他特定转义,还要仔细判断,可以写为如下方式
$dir = 'd:/program files/resource/application/skin/png/';//写成这样的路径,就不用担心转义问题了。最后面的/不要漏写
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if ($file != . && $file != ..)
{
if(filetype($dir . $file) == 'file')
{
$newfile = str_replace(array('_png','_xml','_ico'),array('.png','.xml','.ico'), $file);
var_dump($file.' =======> '.$newfile.'
');
rename($dir . $file, $dir . $newfile);
}
}
}
closedir($dh);
}
以上就介绍了怎么显示文件的扩展名 php中批量替换文件名的实现代码,包括了怎么显示文件的扩展名方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product