Created
October 3, 2016 19:52
-
-
Save ratulcse10/2e0379abe8cac4152942e62f49678293 to your computer and use it in GitHub Desktop.
copy files from one folder to another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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