Move content from one folder to other
Function returns ‘true’ if it is moved all the content from source folder to destination folder otherwise returns ‘false’
Function Definition
function copyr($source, $dest)
{
// Simple copy for a file
if (is_file($source)) {
return copy($source, $dest);
}
// Make destination directory
if (!is_dir($dest)) {
mkdir($dest);
}
// Loop through the folder
$dir = dir($source);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == ‘.’ || $entry == ‘..’) {
continue;
}
// Deep copy directories
if ($dest !== “$source/$entry”) {
copyr(”$source/$entry”, “$dest/$entry”);
}
}
// Clean up
$dir->close();
return true;
}
Function Call
$folder_move=copyr(source,destination);
source->source folder name
destination->destination folder name
Posted by Kalaivani S