PHP function that supports multi-level directory creation. This PHP custom function is a path to create a folder and supports multi-level directory instance functions.
PHP tutorial function that supports multi-level directory creation
This function PHP custom function is a path to create a folder and supports multi-level directory instance functions.
* create_dir (path to create a folder, supports multi-level directories);
*/
function create_dir($dir_adds='') {
$falg = true;
$dir_adds = trim($dir_adds);
if($dir_adds!=''){
$dir_adds = str_replace(array('//','',''),'/' ,$dir_adds);
if (!is_dir($dir_adds)) {
$temp = explode('/',$dir_adds);
$cur_dir = '';
for($i =0;$i$cur_dir .= $temp[$i].'/';
if (!@is_dir($cur_dir)) {
if(!@mkdir($cur_dir,0777))
$falg = false;
}
}
}
return $falg;
}
}
//Look at a directory detection and writing file function
function htm_w(
$w_dir = '',
$w_filename = '',
$w_content = ''
){$dvs = '';
if($w_dir && $w_filename && $w_content){
//Number of directory detections
$w_dir_ex = explode('/ ',$w_dir);
$w_new_dir = ''; //Processed write directory
unset($dvs,$fdk,$fdv,$w_dir_len);
foreach((array)$ w_dir_ex as $dvs){
if(trim($dvs) && $dvs!='..'){
$w_dir_len .= '../';
$w_new_dir .= $dvs. '/';
if (!@is_dir($w_new_dir)) @mkdir($w_new_dir, 0777);
}
}
//Get the directory that needs to be changed Number
foreach((array)$this->filedir as $fdk=>$fdv){
$w_content = str_replace($fdv,$w_dir_len.str_replace('../','', $fdv),$w_content);
}
$this->writer($w_dir.$w_filename,$w_content);
}
}
?>