You can create it easily:
$structure = './depth1/depth2/depth3/';
if (!mkdir($structure, 0, true)) {
die('Failed to create folders...');
}
... You can then use copy()
to duplicate a PHP file, although this sounds incredibly inefficient.
You can create a directory with PHP using the mkdir() function.
mkdir("/path/to/my/dir", 0700);
You can use fopen() to create a file inside that directory with the use of the mode w
.
fopen('myfile.txt', 'w');
w : Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.
In answer to the question in how to write to a file in PHP you can use the following as an example:
$fp = fopen ($filename, "a"); # a = append to the file. w = write to the file (create new if doesn't exist)
if ($fp) {
fwrite ($fp, $text); //$text is what you are writing to the file
fclose ($fp);
$writeSuccess = "Yes";
#echo ("File written");
}
else {
$writeSuccess = "No";
#echo ("File was not written");
}
Source: Stackoverflow.com