Voting

: one minus one?
(Example: nine)

The Note You're Voting On

gimmicklessgpt at gmail dot com
15 years ago
Here's a simple recursive function to copy entire directories

Note to do your own check to make sure the directory exists that you first call it on.

<?php
function recurse_copy($src,$dst) {
$dir = opendir($src);
@
mkdir($dst);
while(
false !== ( $file = readdir($dir)) ) {
if ((
$file != '.' ) && ( $file != '..' )) {
if (
is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else {
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
?>

<< Back to user notes page

To Top