PHP实现递归目录的5种方法

(编辑:jimmy 日期: 2024/10/2 浏览:2)

项目开发中免不了要在服务器上创建文件夹,比如上传图片时的目录,模板解析时的目录等。这不当前手下的项目就用到了这个,于是总结了几个循环创建目录的方法。

方法一:使用glob循环

<"htmlcode">
<"." && $file != "..") {
      $arr[] = $p;
    }
 
    if (is_dir($p) && $file != "." && $file != "..") {
      myscandir2($p, $arr);
    }
  }
}
"htmlcode">
<"." && $file != "..") {
      $arr[] = $p;
    }
    if (is_dir($p) && $file != "." && $file != "..") {
      myscandir3($p, $arr);
    }
  }
}
 "htmlcode">
<"." && $file != "..") {
      $arr[] = $p;
    }
    if (is_dir($p) && $file != "." && $file != "..") {
      myscandir4($p, $arr);
    }
  }
}
 "htmlcode">
 <"htmlcode">
<"\n";
?>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。