Forum Moderators: coopster
<?php
if( isset($_POST['submit']))
{
$start = ($_POST["start"]);
$end = ($_POST["end"]);
for($i=$start; $i<=$end; $i++){
mkdir("/path/to/create/folder/" . $i , 0755);
$file = "/path/to/file/example.txt";
$newfile = "/path/to/file/$i/example.txt.bak";if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
}
}
?>
Now what that is doing is creating the folders I specify in the form, let's say 1 to 5 but it is copying the file(s) into the first folder 5 times. So folders 2 - 5 are empty but folder 1 has 5 text files in it. Any ideas how to fix this? I was told a loop within a loop but I'm lost.
Thanks in advance.