Maison >développement back-end >tutoriel php >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;
}