note 77238 added to function.copy
| From: | swizec at swizec dot com | Date: | Tue, 21 Aug 2007 10:54:25 +0000 |
| Subject: | note 77238 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129665@lists.php.net to get a copy of this message | ||
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 );
}
}
?>
----
Server IP: 213.250.2.28
Probable Submitter: 212.18.43.58
----
Manual Page -- http://www.php.net/manual/en/function.copy.php
Edit -- https://master.php.net/note/edit/77238
Del: integrated -- https://master.php.net/note/delete/77238/integrated
Del: useless -- https://master.php.net/note/delete/77238/useless
Del: bad code -- https://master.php.net/note/delete/77238/bad+code
Del: spam -- https://master.php.net/note/delete/77238/spam
Del: non-english -- https://master.php.net/note/delete/77238/non-english
Del: in docs -- https://master.php.net/note/delete/77238/in+docs
Del: other reasons-- https://master.php.net/note/delete/77238
Reject -- https://master.php.net/note/reject/77238
Search -- https://master.php.net/manage/user-notes.php