note 77238 deleted from function.copy by aidan

From: Date: Wed, 15 Apr 2009 12:23:58 +0000
Subject: note 77238 deleted from function.copy by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153293@lists.php.net to get a copy of this message
Note Submitter: swizec at swizec dot com ---- Here's another recursive copy function. Unlike the others this one relies on the built-in dir class and is thus much cleaner and simpler. <?php 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 ); } } ?>

« previous php.notes (#153293) next »