我有这段代码
<?php
function readFoldersFiles() {
$arrayFolders = array("Circolari", "Comunicazioni varie", "Consuntivi gestione", "estrattor conto", "Preventivi gestione", "Regolamento condominio", "Verbali assemblee");
$dir = '../pdf/'.$GLOBALS['condominio'].'/';
if ($handle = opendir($dir)) {
//create subdirectory
closedir($handle);
}
}
?>
如何从$ arrayFolders
创建子文件夹答案 0 :(得分:1)
foreach( $arrayFolders as $sub){
mkdir($dir . $sub);
}
建议:使用绝对路径。
答案 1 :(得分:1)
<?php
function readFoldersFiles() {
$arrayFolders = array("Circolari", "Comunicazioni varie", "Consuntivi gestione", "estrattor conto", "Preventivi gestione", "Regolamento condominio", "Verbali assemblee");
$dir = '../pdf/'.$GLOBALS['condominio'].'/';
if ($handle = opendir($dir))
{
foreach( $arrayFolders as $array_dir)
{
mkdir($dir . $array_dir);
}
closedir($handle);
}
}
?>
答案 2 :(得分:0)
你可以这样试试:
<?php
function readFoldersFiles() {
$arrayFolders = array("Circolari", "Comunicazioni varie", "Consuntivi gestione", "estrattor conto", "Preventivi gestione", "Regolamento condominio", "Verbali assemblee");
foreach ($arrayFolders as $folder) {
$folderPath = '../pdf/' . $GLOBALS['condominio'] . '/' . $folder;
if (file_exists($folderPath) && is_dir($folderPath)) {
continue;
}
mkdir($folderPath);
}
}
答案 3 :(得分:0)
<?php
function readFoldersFiles() {
$arrayFolders = array("Circolari", "Comunicazioni varie", "Consuntivi gestione", "estrattor conto", "Preventivi gestione", "Regolamento condominio", "Verbali assemblee");
$dir = '../pdf/'.$GLOBALS['condominio'].'/';
if ($handle = opendir($dir)) {
foreach($arrayFolders as $folder){
if(!file_exists($dir.'/'.$folder)) mkdir ($folder);
}
closedir($handle);
}
} ?&GT;