Home > Backend Development > PHP Tutorial > php稽查并创建多级目录

php稽查并创建多级目录

WBOY
Release: 2016-06-13 12:32:29
Original
708 people have browsed it

php检查并创建多级目录

//检查并创建多级目录
?? ?function checkDir($path){
?? ??? ?$pathArray = explode('/',$path);
?? ??? ?$nowPath = '';
?? ??? ?array_pop($pathArray);
?? ??? ?foreach ($pathArray as $key=>$value){
?? ??? ??? ?if ( ''==$value ){
?? ??? ??? ??? ?unset($pathArray[$key]);
?? ??? ??? ?}else{
?? ??? ??? ??? ?if ( $key == 0 )
?? ??? ??? ??? ??? ?$nowPath .= $value;
?? ??? ??? ??? ?else
?? ??? ??? ??? ??? ?$nowPath .= '/'.$value;
?? ??? ??? ??? ?if ( !is_dir($nowPath) ){
?? ??? ??? ??? ??? ?if ( !mkdir($nowPath, 0777) ) return false;
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ?}
?? ??? ?return true;
?? ?}

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template