I have an array $bundlethat stores file names and directory names.
I am running an array with a foreach loop, and I want to move them inside another directory. Therefore, I use the rename method and it works very well with JUST FILES.
However, directories with other files there do not respond to the method rename().
$folder = 'files';
foreach ($bundle as $value) {
$ext = pathinfo($value, PATHINFO_EXTENSION);
if ($ext != "") {
rename(PATH . '/' .$value, $folder . '/' . $value);
}
if ($ext == "") {
}
}
I know that a method is pathinfo()not the best way to find out if it is a directory or not, however for my small project this is normal. I just need to know how I can move any directory with all the contents to the "files" folder.
Thank you for your help.
source
share