Home > php教程 > php手册 > body text

用php循环建立目录

WBOY
Release: 2016-06-06 19:50:41
Original
1100 people have browsed it

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 用php循环建立目录,用在linux系统下。?php /** * 按指定路径生成目录 * @param string $path 路径 */ function mkDirs($path){ $adir = explode('/',$path); $dirlist = ''; $rootdir = array_

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  用php循环建立目录,用在linux系统下。

  /**

  * 按指定路径生成目录

  * @param string $path 路径

  */

  function mkDirs($path){

  $adir = explode('/',$path);

  $dirlist = '';

  $rootdir = array_shift($adir);

  if(($rootdir!='.'||$rootdir!='')&&!file_exists($rootdir)){

  @mkdir($rootdir);

  }

  foreach($adir as $key=>$val){

  $dirlist .= "/".$val;

  $dirpath = $rootdir.$dirlist;

  if(!file_exists($dirpath)){

  @mkdir($dirpath);

  @chmod($dirpath,0777);

  }

  }

  }

  ?>

用php循环建立目录

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