当前位置:首页 > PHP教程 > PHP高级教程

php中批量修改文件后缀名的函数代码

复制代码 代码如下:

<?php
function foreachdir($path){
$handle=opendir($path);
if($handle){
while (false !== ($file = readdir($handle))) {
if($file!="." && $file!='..'){
if(is_dir($path.$file)){
echo $path.$file."<br/>";
foreachdir($path.$file);
}else{
echo "--".$path."/".$file."<br/>";
$ext = strripos($file,'.');
$aaa = substr($file,0,$ext);
rename($path.'/'.$file,$path.'/'.$aaa.'.jpg');
// die();
}
}
}
return false;
}
}
foreachdir('d:xampphtdocstnf2');

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!