Home > php教程 > PHP源码 > body text

php 文件重命名 rename

WBOY
Release: 2016-06-08 17:29:52
Original
1163 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!