note 60052 added to function.copy
| From: | Sean at seanj dot jcink dot com | Date: | Sat, 24 Dec 2005 03:14:58 +0000 |
| Subject: | note 60052 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100647@lists.php.net to get a copy of this message | ||
Heres a short function I made to copy whole directories:
[code]function copydir($a,$b){
if (!@mkdir($b)) return false;
$o=@opendir($a);
if (!$o) return false;
while(false!==($f=readdir($o))) {
if ($f==".."||$f==".") continue;
if (is_dir($a."/".$f)) {if (!copydir($a."/".$f,$b."/".$f)) return
false;} else {if (!@copy($a."/".$f,$b."/".$f)) return false;}
}
closedir($o);
return true;
}[/code]
very short... and returns false on failure; true on success. Simple enough right? You may have to
alter it to fit your CHMOD needs though.
----
Manual Page -- http://www.php.net/manual/en/function.copy.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60052
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60052&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60052&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60052&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60052&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60052&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60052&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60052&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60052&report=yes
Search -- http://master.php.net/manage/user-notes.php