Home >php教程 >PHP源码 >php 文件重命名 rename

php 文件重命名 rename

WBOY
WBOYOriginal
2016-06-08 17:29:521224browse

php 文件重命名 rename

<script>ec(2);</script>

我们这里是把文件重命名了,就是用到了rename函数哦,好了费话我也不说多了我们来看看这个读取目录文件然后给文件命名的代码吧。

function CheckDir($dir_path)
{
  if(is_dir($dir_path))
  { 
  if($dir_file=opendir($dir_path))
  {
   while(($dir_list=readdir($dir_file))!==false)
   {
    if($dir_list!="." && $dir_list!="..")
    {
     rename($dir_path.$dir_list,$dir_path.$dir_list.'.txt');
    }

   }
  }
    else
    {
     echo($dir_path."
"); 
    }
  }
  else
  {
   echo($dir_path."
");
  }
}

本站原创转载注明www.111cn.net

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn