Skip to content

Instantly share code, notes, and snippets.

@justinkelly
Created November 17, 2010 09:45
Show Gist options
  • Save justinkelly/703201 to your computer and use it in GitHub Desktop.
Save justinkelly/703201 to your computer and use it in GitHub Desktop.
recursive copy for php
<?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);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment