代码如下:
$dir = 'd:program files
esourcepplicationskinpng\';//注意这里的路径,最后要加两个,第一个表示转意,但是这样容易遇到其他特定转义,还要仔细判断,可以写为如下方式
$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.' =======youjiankuohaophpcn '.$newfile.'<br />');
rename($dir . $file, $dir . $newfile);
}
}
}
closedir($dh);
}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号