Skip to content

Instantly share code, notes, and snippets.

@ratulcse10
Created October 3, 2016 19:52
Show Gist options
  • Save ratulcse10/2e0379abe8cac4152942e62f49678293 to your computer and use it in GitHub Desktop.
Save ratulcse10/2e0379abe8cac4152942e62f49678293 to your computer and use it in GitHub Desktop.
copy files from one folder to another
function full_copy( $source, $target ) {
if ( is_dir( $source ) ) {
@mkdir( $target );
$d = dir( $source );
while ( FALSE !== ( $entry = $d->read() ) ) {
if ( $entry == '.' || $entry == '..' ) {
continue;
}
$Entry = $source . '/' . $entry;
if ( is_dir( $Entry ) ) {
full_copy( $Entry, $target . '/' . $entry );
continue;
}
copy( $Entry, $target . '/' . $entry );
}
$d->close();
}else {
copy( $source, $target );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment