note 91010 modified in function.copy by danbrown

From: Date: Thu, 21 May 2009 01:04:34 +0000
Subject: note 91010 modified in function.copy by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155812@lists.php.net to get a copy of this message
Here's a simple recursive function to copy entire directories Note to do your own check to make sure the directory exists that you first call it on. <?php function recurse_copy($src,$dst) { $dir = opendir($src); @mkdir($dst); while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) && ( $file != '..' )) { if ( is_dir($src . '/' . $file) ) { recurse_copy($src . '/' . $file,$dst . '/' . $file); } else { copy($src . '/' . $file,$dst . '/' . $file); } } } closedir($dir); } ?> --was-- Here's a simple recursive function to copy entire directories Note to do your own check to make sure the directory exists that you first call it on. function recurse_copy($src,$dst) { $dir = opendir($src); @mkdir($dst); while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) && ( $file != '..' )) { if ( is_dir($src . '/' . $file) ) { recurse_copy($src . '/' . $file,$dst . '/' . $file); } else { copy($src . '/' . $file,$dst . '/' . $file); } } } closedir($dir); } http://php.net/manual/en/function.copy.php

« previous php.notes (#155812) next »