Skip to content

Instantly share code, notes, and snippets.

@msankhala
Created February 3, 2015 10:51
Show Gist options
  • Save msankhala/87cfcf4dab1c0d438fb1 to your computer and use it in GitHub Desktop.
Save msankhala/87cfcf4dab1c0d438fb1 to your computer and use it in GitHub Desktop.
<?php
function recurse_copy($src, $dst) {
$dir = opendir($src);
$result = ($dir === false ? false : true);
if ($result !== false) {
$result = @mkdir($dst);
if ($result === true) {
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' ) && $result) {
if ( is_dir($src . '/' . $file) ) {
$result = recurse_copy($src . '/' . $file,$dst . '/' . $file);
} else {
$result = copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
}
return $result;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment